首先 是从一个西邮学生看到的,比较好的入门方式: 首先是hello.c的文件:主要要说明对内核的编程只能使用内核头文件,所以通常我们都使用makefile来控制编译过程 #include "linux/init.h" #include "linux/module.h" #include "linux/kernel.h" //必选 //模块许可声明 MODULE_LICENSE("Dual BSD/GPL"); //模块加载函数 static int hello_init(void) { printk(KERN_ALERT "hello,I am edsionte/n"); return 0; } //模块卸载函数 14 static void hello_exit(void) 15 { 16 printk(KERN_ALERT "goodbye,kernel/n"); 17 } 18 //模块注册 19 module_init(hello_init); 20 module_exit(hello_exit); 21 //可选 22 MODULE_AUTHOR("edsionte Wu"); 23 MODULE_DESCRIPTION("This is a simple example!/n"); 24 MODULE_ALIAS("A simplest example"); 然后编写Makefile:make的注释 #后面的字符 obj-m += hello.o #generate the path CURRENT_PATH:=$(shell pwd) #the curren