#include <linux/init.h>
#include <linux/module.h>
int a=10;
module_param(a,int,0664);
MODULE_PARM_DESC(a,"this is a value");
char b=97;
module_param(b,byte,0664);
MODULE_PARM_DESC(b,"this is a char");
char *c="hi";
module_param(c,charp,0664);
MODULE_PARM_DESC(c,"this is a character pointer");
short d=13;
module_param(d,short,0664);
MODULE_PARM_DESC(d,"this is a short");
//入口函数 安装内核模块时执行
static int __init mycdev_init(void)
{
printk("a=%d\n",a);
printk("b=%c\n",b);
printk("c=%s\n",c);
printk("d=%d\n",d);
printk("%s:%s:%d\n",__FILE__,__func__,__LINE__);
return 0;
}
//函数出口 卸载内核模块时执行
static void __exit mycdev_exit(void)
{
printk("%s:%s:%d\n",__FILE__,__func__,__LINE__);
}
module_init(mycdev_init);
module_exit(mycdev_exit);
MODULE_LICENSE("GPL");
现象:文章来源:https://www.uudwc.com/A/R6ebo/
文章来源地址https://www.uudwc.com/A/R6ebo/