Hi,
I'm new to Linux Kernel programming, and I need some help on kernel
module programming.
I'm beginning with a simple and useless piece of code :
--- snip
#define __KERNEL__
#define MODULE
#include <linux/module.h>
#include <linux/config.h>
#include <linux/types.h>
#include <linux/errno.h>
#include <linux/fcntl.h>
#include <linux/init.h>
#include <linux/poll.h>
#include <linux/smp.h>
#include <linux/major.h>
#include <asm/processor.h>
#include <asm/msr.h>
#include <asm/uaccess.h>
#include <asm/system.h>
#define MY_MAJOR 119
int init_module (void);
void cleanup_module(void);
static int test_read(struct inode *inode,
struct file *file, char *buffer, int count);
static struct file_operations test_fops =
{
NULL, test_read, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL
int init_module (void)Quote:};
{
printk("Hello kernel\n");
if (register_chrdev(MY_MAJOR,"test",&test_fops))
{
printk("test: unable to get major %d\n",MY_MAJOR);
return -EIO;
}
return 0;
void cleanup_module(void)Quote:}
{
unregister_chrdev(MY_MAJOR,"test");
printk("Bye Kernel\n");
static int test_read(struct inode *inode,Quote:}
struct file *file, char *buffer, int count)
{
int temp;
// if ((temp=verify_area(VERIFY_WRITE,buffer,1)) != 0)
// return 0;
copy_to_user(buffer,banner,1);
return 1;
---- snipQuote:}
As you can see, I try to write a character device driver.
So, here are the problems :
when I compile it with gcc -c myhack.c, then I try to
load it with insmod myhack.o
First, insmod tells me that myhack.o is from a different
kernel version. How do I specify manually that my kernel
version is 2.4.18-686 and not 2.4.18 ?
Then, insmod says that he can't load the module because
he can't links to 'prefetch'
What is prefetch ? I guess that this dependency problem is
related of the different kernel versions. So how do I
solve this dependency ?
Finaly, do I need to need to use verify_area() ?
I have to complain that VERIFY_WRITE is on my computer
undefined...
Thanks for your help.
--
Olivier Matt, alias Init64
$a+=(~$a^$a)>>((log((~$a|$a)+1)/log(2)-1)); # Remplir & dcaler