Insmod is not working

我只是一个虾纸丫 提交于 2019-12-11 16:27:44

问题


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.

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 also don't show any output.

lsmod command is supposed to show all running modules .in my system it gives no output.

This is 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");
}

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

回答1:


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");



来源:https://stackoverflow.com/questions/30783974/insmod-is-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!