a simple kernel module
this is the sample code that i tried to compile in my kernel 2.4-20.8 machine
as gcc -c hello.c # define __KERNEL__ # define MODULE # include <linux/module.h> # include <linux/kernel.h> # include <linux/fs.h> int init_module(void) { struct file_operations fops; return 0; } void cleanup_module(void) { } i referred /usr/include/linux/fs.h and the declaration for file_operations was missing but according to the book by alessandro rubini & corbet they are there in fs.h what is wrong and where ? ~ ~ ~ ~ ~ ~ "hello.c |
fist you dont use the standard includes to compile a kernel module..
you have to use the kernel headers..from whereever your kernel source is : most of the time /usr/src/linux/include and then you have to specify -DMODULE -D__KERNEL__ to specify that this is for the kernel.. please read the linux device drivers...before starting with the core kernel stuff.. it does give you a sample makefile for the purpose..you might have to put an extra compiler switch like : -nostdinc (to prevent it from picking /usr/include stuff).. |
shishir: hari_sasidharan has already defined MODULE and __KERNEL__, look at the code source.
|
Well the compilation works with the command line statement that he has used. try grepping the file_operations from the directory /usr/include. It must be in the fs.h.
|
All times are GMT -5. The time now is 08:44 AM. |