亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 7965 | 回復: 7
打印 上一主題 下一主題

[內核模塊] call_usermodehelper()返回值-2 [復制鏈接]

論壇徽章:
0
跳轉到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2012-07-30 17:17 |只看該作者 |倒序瀏覽
請教一個關于call_usermodehelper()的問題,我怎么試都是返回-2,我的應用程序test,放在/bin/test下,在/bin目錄下執(zhí)行./test是沒有問題,但是通過內核執(zhí)行時就出現(xiàn)返回值-2,在內核時執(zhí)行如下代碼,可是一直沒有辦法執(zhí)行到test,這是為什么。。。恐x謝大家。

void test_call_usermode(void)
{
        int iRet;
        char *argv[2], *envp[3];


    /* set up a minimal environment */
        iRet = 0;
        envp[iRet++] = "HOME=/";
        envp[iRet++] = "PATH=/sbin:/usr/sbin:/bin:/usr/bin";
        envp[iRet] = NULL;

        /* set up the argument list */
        iRet = 0;
        argv[iRet++] = "/bin/test";
        argv[iRet] = NULL;

        /* call ifconfig to configure the virtual network interface */
        iRet = call_usermodehelper(argv[0], argv, envp, 0);
        //iRet = kernel_execve(argv[0], argv, envp);
        printk("ifconfig %s %s returned %d\n", argv[1], argv[2], iRet);

}

論壇徽章:
0
2 [報告]
發(fā)表于 2012-07-31 09:21 |只看該作者
高手們幫個忙咯,項目比較急!!謝謝大家!

論壇徽章:
0
3 [報告]
發(fā)表于 2012-08-02 09:43 |只看該作者
等著大家:wink:

論壇徽章:
0
4 [報告]
發(fā)表于 2012-08-02 10:29 |只看該作者
-2是no such file or directory,  是不是運行到這的時候文件系統(tǒng)還沒掛載?

論壇徽章:
0
5 [報告]
發(fā)表于 2012-08-02 21:38 |只看該作者
這種問題review一下call_usermodehelper的code啊....

看看是哪一步fail了,4樓說的我覺得也有可能....  

論壇徽章:
0
6 [報告]
發(fā)表于 2012-08-02 21:52 |只看該作者
回復 4# wwxbei

在文件Main.c (init)        22491        2012/3/22中的如下代碼中調用的
/* This is a non __init function. Force it to be noinline otherwise gcc
* makes it inline to init() and it becomes part of init.text section
*/
static noinline int init_post(void)
{
        /* need to finish all async __init code before freeing the memory */
        async_synchronize_full();
        free_initmem();
        mark_rodata_ro();
        system_state = SYSTEM_RUNNING;
        numa_default_policy();


        current->signal->flags |= SIGNAL_UNKILLABLE;

             //此處調用的那個包含call_usermodehelper()的函數(shù)
        if (ramdisk_execute_command) {
                run_init_process(ramdisk_execute_command);
                printk(KERN_WARNING "Failed to execute %s\n",
                                ramdisk_execute_command);
        }

        /*
         * We try each of these until one succeeds.
         *
         * The Bourne shell can be used instead of init if we are
         * trying to recover a really broken machine.
         */
        if (execute_command) {
                run_init_process(execute_command);
                printk(KERN_WARNING "Failed to execute %s.  Attempting "
                                        "defaults...\n", execute_command);
        }
        run_init_process("/sbin/init");
        run_init_process("/etc/init");
        run_init_process("/bin/init");
        run_init_process("/bin/sh");

        panic("No init found.  Try passing init= option to kernel. "
              "See Linux Documentation/init.txt for guidance.");
}
按理說文件系統(tǒng)已經起來了,接著是啟動Android了。并且用call_usermodehelper()調用了/bin/ls,返回值就不是-2了,但是看不到調用后結果,LOG中看不到當前目錄下的文件列表,因此還有一個問題:執(zhí)行call_usermodehelper()后的那個應用程序結果從那里顯示打印信息。

另外還試了run_init_process()這個函數(shù),那個應用程序也是執(zhí)行不成功的。
   

論壇徽章:
0
7 [報告]
發(fā)表于 2012-08-02 22:02 |只看該作者
onlyxuyang 發(fā)表于 2012-08-02 21:38
這種問題review一下call_usermodehelper的code啊....

看看是哪一步fail了,4樓說的我覺得也有可能....


是在Namei.c (fs)        90057        2012/3/22文件中如下函數(shù)
static int link_path_walk(const char *name, struct nameidata *nd)中出錯的如下代碼處出錯,并返回的

                err = do_lookup(nd, &this, &next, &inode);
                if (err)
                        break;
                if (inode && unlikely(inode->i_op->follow_link) &&  //inode->i_op->follow_link不能訪問的,inode似乎是空的,待續(xù)ING,目前在追前面的do_lookup函數(shù)
                    (lookup_flags & LOOKUP_FOLLOW)) {
                        err = do_follow_link(inode, &next, nd);
                        if (err)
                                goto return_err;
                        nd->inode = nd->path.dentry->d_inode;
                } else {//執(zhí)行了else
                        path_to_nameidata(&next, nd);
                        nd->inode = inode;
                }
                err = -ENOENT;//#define        ENOENT                 2        /* No such file or directory */
                if (!nd->inode)
                        break;//從這里退出的

論壇徽章:
0
8 [報告]
發(fā)表于 2013-10-03 17:26 |只看該作者
call_usermodehelper的第三個參數(shù)改為1試試
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復

  

北京盛拓優(yōu)訊信息技術有限公司. 版權所有 京ICP備16024965號-6 北京市公安局海淀分局網監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關心和支持過ChinaUnix的朋友們 轉載本站內容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP