writing driver modules
Hi!
I am having trouble with the first stage of my mission.
I am trying to compile some code to make a beginners module.
When I compile it I get some errors.
1)
It doesn't know what KERN_INFO is
I looked at the /usr/include/linux/kernel.h and it only has 1 sysinfo struct in there.
I did a search on the kernel.h file and other ones I found had the #defines in them which is how I knew what to write. I added this line into my own source file which removed the error...
#define KERN_INFO "<6>"
2) I compile it 'gcc -c driver.c' #and it happily creates a driver.o file
I then go 'insmod -f ./driver.o'
Warning: kernel-module version mismatch
./driver.o was compiled for kernel version 2.4.9-9
while this kernel is version 2.4.20-24.8
Am I doing this right?
#define MODULE
#include <linux/module.h>
#include <linux/kernel.h>
int init_module(void)
{
printk(KERN_INFO "Hello, world\n");
return 0;
}
void cleanup_module(void)
{
printk(KERN_INFO "Goodbye cruel world\n");
}
I am running Redhat 8.0 with 2.4.20-24 kernel & Redhat 9 2.4.20-8
Has anyone tryed this before?
|