// This function is called when driver is installed by insmod
int init_module(void)
{
printk("<1>init_module: Hello World!\n");
return 0; // return 0 means success; any other value means failure
}
// This function is called when driver is uninstalled by rmmod
void cleanup_module(void)
{
printk("<1>cleanup_module: Hello World cleaning up....\n");
}
编译出现警告:
love.c: In function `init_module':
love.c:30: warning: implicit declaration of function `printk'
使用insmod可以加载,没有警告,不过也没有打印输出!
使用rmmod,提示rmmod: module love.o is not loaded,比较奇怪,明明lsmod 里有的
使用 modprobe -r love.o可以卸载掉