Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1213480
  • 博文数量: 261
  • 博客积分: 4196
  • 博客等级: 上校
  • 技术积分: 3410
  • 用 户 组: 普通用户
  • 注册时间: 2012-02-17 17:05
文章分类

全部博文(261)

文章存档

2018年(1)

2017年(22)

2016年(2)

2015年(8)

2014年(27)

2013年(40)

2012年(161)

分类: LINUX

2012-08-11 14:22:16

from://blog.csdn.net/wby0322/article/details/5702040
使用rmmod会出现 rmmod : chdir(/lib/modules): No such file or directory ?
    现在的内核模块在插入卸载时都会要转到/lib/modules/内核版本号/ 这个目录里。所以只要建立这个目录并且把要使用的模块.ko文件复制到这个目录就行了。
解决办法:在/lib/下建立下面的目录: /lib/modules/2.6.30.4   并且把Albert_hello.ko 模块放到2.6.30.4目录下(实际上不用放到这目录也行)
          mkdir -p /lib/modules/$(uname -r)
这个语句不要加到制作ramdisk的脚本中,要加到rc文件中。
较新版本的busybox 1.13.1+ 要卸载模块必须要 “完全匹配模块名”才行,原来在老标本的使用模块文件名就能卸载,现在发现不行了。
[root@Real6410 1.0]# lsmod
mmc_block 9668 0 - Live 0xbf03a000
mmc_core 48000 1 mmc_block, Live 0xbf029000
这里面mmc_block和mmc_core为“完全匹配模块名”,而不是mmc_block.ko  mmc_core.ko 这样的模块文件名

另一种方案:

必须创建/lib/modules/2.6.30.4这样一个空目录,否则不能卸载ko模块.

# rmmod nls_cp936
rmmod: chdir(/lib/modules): No such file or directory
但是这样倒是可以卸载nls_cp936,不过会一直有这样一个提示:
rmmod: module 'nls_cp936' not found


初步发现,原来这是编译kernel时使用make modules_install生成的一个目录,

但是经测试得知,rmmod: module 'nls_cp936' not found来自于busybox,并不是来自kernel,

1.创建/lib/modules/2.6.30空目录就.

2.使用如下源码生成rmmod命令,就可以没有任何提示的卸载ko模块了[luther.gliethttp]

#include

#include

#include

#include

#include

#include

int main(int argc, char *argv[])

{

const char *modname = argv[1];

int ret = -1;

int maxtry = 10;

while (maxtry-- > 0) {

ret = delete_module(modname, O_NONBLOCK | O_EXCL);//系统调用sys_delete_module

if (ret < 0 && errno == EAGAIN)

usleep(500000);

else

break;

}

if (ret != 0)

printf("Unable to unload driver module \"%s\": %s\n",

modname, strerror(errno));

}

 

3.把生成的命令复制到文件系统

# arm-linux-gcc -static -o rmmod rmmod.c

# arm-linux-strip -s rmmod

# cp rmmod /nfs/

cp /nfs/rmmod /sbin

阅读(779) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~