[英]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.