My Tech notes: Calling User Space Program From Kernel Space

Unix Documentation

Free Online Unix Training Materials

Lists many links to free Unix training materials.

Pointers and Arrays Materials

Pointers and Arrays materials Explained for C beginners

C FAQ and General Questions C Interview Questions

Powered By

Free XML Skins for Blogger

Powered by Blogger

Monday, December 15, 2008

Calling User Space Program From Kernel Space

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.


Kernel Module:

char name[]="user_program";

static int init_function(void)
int ret;
char *argv[] = {name, "hello", "world", NULL };
static char *envp[] = { "HOME=/",

printk("We r in init_function\n");

ret= call_usermodehelper(name, argv, envp, 1);
if ( ret <>
int main(int argc,char *argv[],char *envp[])
int i=0,fd;

if( fd <>

No comments:

Post a Comment