How to write a kernel module(kernel object, .ko) on linux-2.6.0?
here is an example, anything wrong ?
//---------hello.c---------------- #include <linux/kernel.h> #include <linux/module.h> int init_module(void) { printk("hello world\n"); return 0; } void cleanup_module(void) { printk("bye\n"); } //------end of hello.c------- I compiled it with command: gcc -I/usr/src/linux-2.6.0-test7/include -D_KERNEL_ -DMODULE -DKBUILD_MODNAME=hello -c hello.c ant then I got may "undeclared" errors. This is the first time for me to write kernel module on 2.6, and I even don't know how to generate a .ko file. :( |
Disclaimer: I don't know about 2.6 kernel internals.
If they mostly work as 2.4, one of the flags should be '-D__KERNEL__' Also I would recommend the Linux device drivers book (still on 2.4, but should be applicaple to 2.6 in some extent). |
All times are GMT -5. The time now is 04:20 AM. |