Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

call_usermodehelper / call_usermodehelperpipe usage

Tags:

c

linux

kernel

I've followed this great document on invoking user apps from the kernel: http://www.ibm.com/developerworks/linux/library/l-user-space-apps/index.html

But I'm now interested in how to get the output from the apps that have been run. I tried passing in redirection operators to write the output to a file.. Eg:

char *argv[] = { "/usr/bin/ls", ">>", "/tmp/list", NULL};
call_usermodehelper(argv[0], argv, envp, UMH_WAIT_PROC);

No such luck. I came across call_usermodehelperpipe and wondered if that would be what I'm after, but I haven't been able to grasp how to use it or find any documents like the above one on it.

Thanks in advance for suggestions / help!

like image 535
Rex Avatar asked Aug 22 '11 04:08

Rex


1 Answers

>> is not an argument for ls, it is something from the shell. It can be parsed using/bin/sh -c "ls >> /tmp/list" (in shell). In C, this is:

char *argv[] = { "/bin/bash", "-c", "/bin/ls >> /tmp/list", NULL};
like image 135
J-16 SDiZ Avatar answered Sep 30 '22 01:09

J-16 SDiZ