2

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.

Is it correct to do this? What would be the best way to call a binary from inside the linux kernel? system(), popen()?

Thanks for your answer.

fazineroso
  • 7,196
  • 7
  • 31
  • 42
  • 1
    binary is a kernel module or user space application???? need more clarification on external binary. – Jeyaram Jul 16 '12 at 11:32
  • I hope the [this](http://stackoverflow.com/questions/6861909/popen-vs-system-is-popen-as-evil-as-system) will help you. – Jeyaram Jul 16 '12 at 11:56
  • 2
    Well, I found this, I think it may help me: http://www.ibm.com/developerworks/linux/library/l-user-space-apps/index.html – fazineroso Jul 16 '12 at 12:10
  • 1
    @fazineroso that's correct; you should write that as an answer! – ecatmur Jul 16 '12 at 12:30

1 Answers1

5

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. The example is self-explanatory. Source: http://www.ibm.com/developerworks/linux/library/l-user-space-apps/index.html

fazineroso
  • 7,196
  • 7
  • 31
  • 42