简体   繁体   中英

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):

    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.

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. 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.

The correct way to do this would be through a udev rule . If you really don't want to use udev for some reason, you can use the usermode helper API ( example ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM