|
程序如下:
#define __NO_VERSION__
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
/* Deal with CONFIG_MODVERSIONS */
#if CONFIG_MODVERSIONS==1
#define MODVERSIONS
#include <linux/modversions.h>
#endif
MODULE_LICENSE("GPL");
// 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可以卸载掉
如何消除那个警告呢?
为什么在终端里没有输出呢?
谢谢 |
|