Help - Search - Members - Calendar
Full Version: Wrting Modules
Linuxhelp > Support > Technical Support
i tried writing modules on my system.i am follwing allessandro rubini book.i have written a simple hello world module and tried to insert it.but i got errors like.

this module is written for kernel 2.4.9
but the current kernel is 2.4.18

then i checked the header files and found that indeed some header are using 2.4.9 as the kernel.then i tried to manually modify them and thried to compile the module again but still no luck.
I have absolutly no idea on creating, modifying or doing anything with modules except insert and probe (and maybe build), so I have no idea how it's set up. The only suggestion I can make is to make sure that the code is refrencing the proper kernel headers in /usr/src . Make sure you have the source tree for the 2.4.18 kernel in /usr/src/linux-2.4.18 and make a symlink to /usr/src/linux pointing to that source tree. While writing the code, point it to look for headers in /usr/src/linux .

Out of curiosity, can you paste your code in here? I wanna see how you do it smile.gif I've always been interesting in writing modules. If you could give more info on the book you have it would be nice too. smile.gif
Here goes my code..
#define MODULE
int init_module(void)
printk("<1>Hello worldn");
return 0;
void cleanup_module(void)
printk("<1>good bye cruel worldn");

No big module just a hello module.
i compile using
#gcc -c hello.c -I /usr/src/linux/include
it gets compiled without problem.but when i try to insert the module using the command
#insmod hello.o
i get errors like the module has been compiled for kerenl 2.4.9 but the current kernel is 2.4.18

The book i am refering is a device driver book by Alessandro rubini.If interested u can follow the link

the book is not free and i got this book from my college library.
sorry the book is free u can check the latest edition here
Okay, it sounds like it's using header files from a 2.4.9 kernel tree. Are you absolutly sure that the kernel source located in /usr/src/linux is indeed the 2.4.18 kernel tree? I'm not sure how to exactly check, maybe it mentions the version number in /usr/src/linux/include/kernel.h ?

Otherwise, I cannot see any other reason why a kernel module would think it's compiling with a 2.4.9 kernel.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2017 Invision Power Services, Inc.