rmmod: chdir(/lib/modules): No such file or directory 解决方法

转自:http://www.cnblogs.com/feisky/archive/2010/05/29/1746888.html

在开发板卸载模块的时候可以卸载模块,不过会一直有这样一个提示:
rmmod: module '×××' not found

使用如下源码生成rmmod命令,就可以没有任何提示的卸载模块了

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
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));
}


把生成的命令复制到文件系统
# arm-linux-gcc -static -o rmmod rmmod.c
# arm-linux-strip -s rmmod
# cp rmmod /nfs/
cp /nfs/rmmod /sbin

posted @ 2013-01-17 14:02  wust.zjf  阅读(534)  评论(0编辑  收藏  举报