gpt4 book ai didi

linux - insmod : ERROR: could not insert module HelloWorld. ko: 不允许操作

转载 作者:行者123 更新时间:2023-12-04 11:57:46 26 4
gpt4 key购买 nike

我正在尝试学习 linux 和内核开发。

我能够构建模块但无法加载它。

HelloWorld.c

/*  
* hello-1.c - The simplest kernel module.
*/
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_INFO */

int init_module(void)
{
printk(KERN_INFO "Hello world 1.\n");

/*
* A non 0 return means init_module failed; module can't be loaded.
*/
return 0;
}

void cleanup_module(void)
{
printk(KERN_INFO "Goodbye world 1.\n");
}

这是我的制作文件:
KERNEL_SOURCE := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)

obj-m += HelloWorld.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

在执行 insmod 加载模块权限时被拒绝。我什至尝试使用 root 和 modprobe 进行此操作,但没有用。

我也试过 Link但问题还是一样。

希望我能得到一些帮助。我正在使用 ubuntu 18.04LTS。

最佳答案

所以我遇到了同样的问题,这对我有用:

  • 您需要使用 mokutil use the first answer in this link 禁用安全启动
  • 通过 sudo 运行 insmod 命令。

  • 祝你好运。

    关于linux - insmod : ERROR: could not insert module HelloWorld. ko: 不允许操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58546126/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com