Invoking user mode application from kernel modules, yes its possible with help of CALL_USERMODEHELPER.
With the following kernel API, we can invoke user mode application from Kernel modules/threads.
int call_usermodehelper (char * path, char ** argv, char ** envp, int wait);
path: pathname for the application.
argv: null-terminated argument list.
envp: null-terminated environment list.
wait: wait for application to finish and return status.
Example:
Kernel Module:
#include
#include
char name[]="user_program";
static int init_function(void)
{
int ret;
char *argv[] = {name, "hello", "world", NULL };
static char *envp[] = { "HOME=/",
"TERM=linux",
"PATH=/sbin:/usr/sbin:/bin:/usr/bin",
NULL };
printk("We r in init_function\n");
ret= call_usermodehelper(name, argv, envp, 1);
if ( ret <>
#include
int main(int argc,char *argv[],char *envp[])
{
int i=0,fd;
fd=open("/dev/ttyMCS",O_WRONLY);
if( fd <>
With the following kernel API, we can invoke user mode application from Kernel modules/threads.
int call_usermodehelper (char * path, char ** argv, char ** envp, int wait);
path: pathname for the application.
argv: null-terminated argument list.
envp: null-terminated environment list.
wait: wait for application to finish and return status.
Example:
Kernel Module:
#include
#include
char name[]="user_program";
static int init_function(void)
{
int ret;
char *argv[] = {name, "hello", "world", NULL };
static char *envp[] = { "HOME=/",
"TERM=linux",
"PATH=/sbin:/usr/sbin:/bin:/usr/bin",
NULL };
printk("We r in init_function\n");
ret= call_usermodehelper(name, argv, envp, 1);
if ( ret <>
#include
int main(int argc,char *argv[],char *envp[])
{
int i=0,fd;
fd=open("/dev/ttyMCS",O_WRONLY);
if( fd <>
Comments