问题描述
insmod
/rmmod
无法识别参数.即使没有任何参数的insmod
也将被执行.看来系统只能识别命令.
insmod
/rmmod
doesn't recognize the arguments. Even insmod
without any argument also gets executed. It looks like only command is recognized by the system.
通过insmod
命令内核模块可以动态插入,但是当我执行insmod testStub.ko
时,什么都没有发生.在lsmod
结果中我都看不到我的模块,在dmesg
中我写在testStub.c
中的任何printk
消息也都看不到.
Through insmod
command kernel module can be inserted dynamically but when I do insmod testStub.ko
, nothing is happening. Neither do I see my module in lsmod
result nor any printk
messages that I have written in my testStub.c
, in dmesg
.
lsmod
/modprobe -l
也不会显示任何输出.
lsmod
/modprobe -l
also don't show any output.
lsmod
命令应该显示所有正在运行的模块.在我的系统中,它没有任何输出.
lsmod
command is supposed to show all running modules .in my system it gives no output.
这是testStub.c
:
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_INFO */
int init_module(void)
{
printk(KERN_EMERG "Module Attached");
return 0;
}
void cleanup_module(void)
{
printk(KERN_INFO "Module Detached!\n");
}
这是Makefile:
This is Makefile:
obj-m += testStub.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
推荐答案
您的源文件缺少模块许可证,这在尝试插入模块时会污染内核.在您的源代码中添加以下行以使其正常工作.
Your source file is missing module license this taints the kernel when you try to insert the module. add below line to your source code to make it work.
MODULE_LICENSE("GPL");
这篇关于Insmod不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!