这是简单的模块程序代码。
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_INFO */
#include <linux/init.h> /* Needed for the macros */
static int hello3_data __initdata = 3;
static int __init hello_3_init(void)
{
printk(KERN_INFO "Hello, world %d\n", hello3_data);
return 0;
}
static void __exit hello_3_exit(void)
{
printk(KERN_INFO "Goodbye, world %d\n",hello3_data);
}
module_init(hello_3_init);
module_exit(hello_3_exit);
我已经用__initdata
宏初始化了一个变量,用__init
. 当我insmod
插入模块时,我能够看到日志消息(/var/log/messages)。但是,当我这样做时,rmmod
它无法删除它,它说Resource busy
.
My question is does the `modules_init` function cleans the memory of `hello3_data`??
or it is done by `module_exit`??.
有人请解释一下。