简体   繁体   English

从Linux内核运行外部二进制文件

[英]Running an external binary from the Linux Kernel

In our development team we are modifying a driver for our own needs. 在我们的开发团队中,我们正在根据自己的需求修改驱动程序。 We need it to execute an external binary (user space application) in the linux filesystem. 我们需要它在linux文件系统中执行外部二进制文件(用户空间应用程序)。

Is it correct to do this? 这样做正确吗? What would be the best way to call a binary from inside the linux kernel? 从Linux内核内部调用二进制文件的最佳方法是什么? system(), popen()? system(),popen()?

Thanks for your answer. 感谢您的回答。

Well, I found a very well explained solution to my question. 好吧,我找到了一个很好解释我的问题的解决方案。

char *argv[] = { "/usr/bin/logger", "help!", NULL };
static char *envp[] = {
    "HOME=/",
    "TERM=linux",
    "PATH=/sbin:/bin:/usr/sbin:/usr/bin", NULL };

return call_usermodehelper( argv[0], argv, envp, UMH_WAIT_PROC );

I need to use the call_usermodehelper system calls. 我需要使用call_usermodehelper系统调用。 The example is self-explanatory. 这个例子是不言自明的。 Source: http://www.ibm.com/developerworks/linux/library/l-user-space-apps/index.html 来源: http//www.ibm.com/developerworks/linux/library/l-user-space-apps/index.html

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

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