- ubuntu 9.04
- kernel 2.6.28-15-generic
sample code:
#include#include/* Needed by all modules */ #include/* Needed for KERN_INFO */ #include/* Needed for the macros */ static int __init hello_start(void){printk(KERN_INFO "Loading hello module...\n");printk(KERN_INFO "Hello world\n");return 0;}static void __exit hello_end(void){printk(KERN_INFO "Goodbye Mr.\n");}module_init(hello_start);module_exit(hello_end);
instruction guide:
sudo apt-get install linux-headers-`uname -r`vi hello.c
copy the code into it
vi Makefile
insert
obj-m := nothing.o
in the command line type
make -C /lib/modules/`uname -r`/build M=`pwd` modules
No comments:
Post a Comment