hello.c
/*hello.c*/#include#include #include MODULE_LICENSE("Dual BSD/GPL");static int hello_init(void){ printk(KERN_EMERG "Hello,world!\n"); return 0;}static void hello_exit(void){ printk(KERN_EMERG"Goodbye,world!\n");}module_init(hello_init);module_exit(hello_exit);
Makefile:
KERNEL_DIR:=/usr/src/
obj-m:=hello.o default: $(MAKE) -C $(KERNEL_DIR) SUBDIRS=$(PWD) modules clean:......
# make -C /lib/modules/2.6.32-24-generic/build/ M=/home/darxin/helloWorld/ modules
......
# insmod hello.ko
......
# rmmod hello.
......