开发板上rmmod卸载模块必须创建/lib /modules/2.6.30.4这样一个空目录

必须创建/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生成的一个目录,


luther@gliethttp:/vobs/works/linux-2.6.30.4$ make modules_install INSTALL_MOD_PATH=/vobs/gliethttp
luther@gliethttp:/vobs/works/linux-2.6.30.4$ tree /vobs/gliethttp/
/vobs/gliethttp/
`-- lib
    `-- modules
        `-- 2.6.30.4
            |-- build -> /vobs/works/linux-2.6.30.4
            |-- kernel
            |   |-- drivers
            |   |   `-- scsi
            |   |       `-- scsi_wait_scan.ko
            |   `-- fs
            |       `-- nls
            |           `-- nls_cp936.ko
            |-- modules.alias
            |-- modules.ccwmap
            |-- modules.dep
            |-- modules.ieee1394map
            |-- modules.inputmap
            |-- modules.isapnpmap
            |-- modules.ofmap
            |-- modules.order
            |-- modules.pcimap
            |-- modules.seriomap
            |-- modules.symbols
            |-- modules.usbmap
            `-- source -> /vobs/works/linux-2.6.30.4

10 directories, 14 files
然后将上面生成的 modules目录拷贝到开发板的/lib下即可.
也可以直接释放到initramfs中
luther@gliethttp:/vobs/works/linux-2.6.30.4$ make modules_install INSTALL_MOD_PATH =/vobs/initramfs
但 是kernel目录下的包含了所有.ko,这是我所不期望的,因为我把.ko放在一个我们独立的存储区,
但是将kernel目录删除之后,就又会 提示:rmmod: module 'nls_cp936' not found , 当然模块是已经卸载了,但有这种提示总让人感觉怪怪的,
所以上面的拷贝就没有了意义,
luther@gliethttp:/vobs/initramfs/lib/modules/2.6.30.4$ rm -rf build kernel source
后来发现提示:rmmod: module 'nls_cp936' not found来自于busybox, 并不是来自kernel,
所以使用如下源码生成rmmod命 令,就可以没有任何提示的卸载ko模块了[luther.gliethttp]

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

luther@gliethttp:/vobs/tmp$ arm-linux-gcc -o rmmod rmmod.c
luther@gliethttp:/vobs/tmp$ arm-linux-strip -s rmmod
luther@gliethttp:/vobs/tmp$ cp rmmod /vobs/nfs/
这样只需要创建/lib/modules/2.6.30.4空目录就完全可以了.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值