rmmod: chdir(/lib/modules): No such file or directory

针对飞凌6410中动态卸载驱动时候出现rmmod: chdir(/lib/modules): No such file or directory怎么解决?

1.在文件系统目录中创建/lib/modules/3.0.1这个空目录

2.查看/sbin中是否有rmmod,如果没有,静态编译如下代码,将生成的rmmod放入/sbin中

 

#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));
}

 

 

posted @ 2013-04-22 17:06  坚固66  阅读(120)  评论(0编辑  收藏  举报