1
我剛從模塊化編程入手。內核模塊編程中的insmod錯誤
以上是我的兩個文件:
的hello.c
#include <linux/init.h>
#include <linux/module.h>
static int hello_init(void)
{
printk(KERN_ALERT "TEST: Hello world\n");
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT "TEST: Good Bye");
}
module_init(hello_init);
module_exit(hello_exit);
的Makefile
obj-m += hello.o
KDIR = /usr/src/linux-headers-3.13.0-46-generic
all:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
clean:
rm -rf *.o *.ko *.mod.* *.symvers *.order
這是我的終端輸出,顯示在insmod命令錯誤,請幫助。
[email protected]:~/Desktop/os$ make
make -C /usr/src/linux-headers-3.13.0-46-generic SUBDIRS=/home/anubhav/Desktop/os modules
make[1]: Entering directory `/usr/src/linux-headers-3.13.0-46-generic'
Building modules, stage 2.
MODPOST 1 modules
make[1]: Leaving directory `/usr/src/linux-headers-3.13.0-46-generic'
[email protected]:~/Desktop/os$ insmod hello.ko
insmod: ERROR: could not insert module hello.ko: Operation not permitted
只有'root'用戶通常有權插入/刪除內核模塊。或者['su'](http://en.wikipedia.org/wiki/Su_%28Unix%29)改爲'root',或者使用['sudo'](http://en.wikipedia.org/wiki/) Sudo)(如果適用)以root身份運行該命令。 – lsowen 2015-03-13 16:12:22
@lsowen我嘗試過「su」和「su - 」。但提供密碼後,我得到味精「蘇:認證失敗」。任何其他方式繼續前進 – anubhav 2015-03-13 16:17:55
此消息表示您輸入了錯誤的密碼(或不是允許成爲root的用戶組的成員)。您需要在'su'處使用的密碼是'root'密碼,而不是您的用戶密碼。 – lsowen 2015-03-13 16:19:15