简体   繁体   English

错误:函数'execl'的隐式声明[-Werror = implicit-function-declaration]

[英]error: implicit declaration of function 'execl' [-Werror=implicit-function-declaration]

I am trying to use execl call to execute a binary in kernel-space-driver (driver.c) at this point(line no. 850 onward): 我试图在此时使用execl调用在内核空间驱动程序(driver.c)中执行二进制文件(从850号行开始):

    if (!retval)

{
        pr_info("%s: registered new device driver %s\n",
            usbcore_name, new_udriver->name);
 execl("binarylocation", "binary", NULL);

}

I have also added the #include < linux/unistd.h> in the file. 我还在文件中添加了#include <linux / unistd.h>。

But when the kernel is build I get the following error: 但是在构建内核时,出现以下错误:

error: implicit declaration of function 'execl' [-Werror=implicit-function-declaration]

and thus the kernel failed to built. 因此内核无法构建。

And one warning is coming: 一个警告即将到来:

 warning: incompatible implicit declaration of built-in function 'execl' [enabled by default]

Why are these errors and warning coming, even though the required header files are included? 即使包含必需的头文件,为什么还会出现这些错误和警告?

execl is provided by libc, which is user-mode. execl由libc提供,它是用户模式。 In addition, exec functions replace the current process, but that context in the kernel doesn't really have a "current process" you'd want to be replacing. 另外, exec函数将替换当前进程,但是内核中的上下文实际上并没有要替换的“当前进程”。

The correct way to do this would be through a udev rule . 正确的方法是通过udev规则 If you really don't want to use udev for some reason, you can use the usermode helper API ( example ). 如果您确实出于某种原因不想使用udev,可以使用usermode helper API示例 )。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:函数“rdtscl”的隐式声明 [-Werror=implicit-function-declaration](但在旧内核版本上运行时没有错误) - error: implicit declaration of function 'rdtscl' [-Werror=implicit-function-declaration] (but no error when running on older kernel version) rtw_android.c错误:函数&#39;strnicmp&#39;的隐式声明[-Werror = implicit-function-declaration] - rtw_android.c error: implicit declaration of function ‘strnicmp’ [-Werror=implicit-function-declaration] 错误:函数&#39;create_proc_read_entry&#39;的隐式声明[-Werror = implicit-function-declaration] - error: implicit declaration of function 'create_proc_read_entry' [-Werror=implicit-function-declaration] 错误:隐式声明 function 'memcpy_s'; 您指的是 'memcpy' 吗? [-Werror=隐式函数声明] - error: implicit declaration of function ‘memcpy_s’; did you mean ‘memcpy’? [-Werror=implicit-function-declaration] elfutils编译错误implicit-function-declaration - elfutils compilation error implicit-function-declaration 函数 &#39;str[n]casecmp&#39; 的隐式声明 [-Werror=implicit-function-declaration] - implicit declaration of function ‘str[n]casecmp’ [-Werror=implicit-function-declaration] 隐式声明函数错误 - Implicit declaration of function error 错误:函数的隐式声明 - Error: Implicit declaration of function 函数“execle”错误的隐式声明 - implicit declaration of function 'execle' error 错误:function 'rl_replace_line' 的隐式声明在 C99 中无效 [-Werror,-Wimplicit-function-declaration] - error: implicit declaration of function 'rl_replace_line' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM