本文介绍了Insmod不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-30 11:45