-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinvoke-userlevel-app.c
68 lines (30 loc) · 1.39 KB
/
invoke-userlevel-app.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <linux/init.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
//# include <linux/config.h>
#include <linux/kernel.h> /* printk () */
#include<linux/sched.h>
MODULE_LICENSE ( "GPL" );
static __init int testDriver1_init ( void ) {
int result = 0;
char cmdPath [] = "/bin/ls" ;
char * cmdArgv [] = {cmdPath, "> /xxxx" , NULL};
char * cmdEnvp [] = { "HOME =/" ,
"PATH =/sbin :/bin:/usr/bin" , NULL};
result = call_usermodehelper (cmdPath, cmdArgv, cmdEnvp, UMH_WAIT_PROC);
printk (KERN_DEBUG "testDriver1_init exec ! Theresult of call_usermodehelper is% d\n" , result);
printk (KERN_DEBUG "testDriver1_init exec ! Theprocess is\"% s\", pid is% d, sys_getpid is% d\n" , current-> comm, current-> pid);
return result;
}
static __exit void testDriver1_exit ( void ) {
int result = 0;
char cmdPath [] = "/bin/rm " ;
char * cmdArgv [] = {cmdPath, "/touchX.txt" , NULL};
char * cmdEnvp [] = { "HOME =/" ,
"PATH =/sbin :/bin:/usr/bin" , NULL};
result = call_usermodehelper (cmdPath, cmdArgv, cmdEnvp, UMH_WAIT_PROC);
printk (KERN_DEBUG "testDriver1_exit exec ! Theresult of call_usermodehelper is% d\n" , result);
printk (KERN_DEBUG "testDriver1_exit exec ! Theprocess is\"% s\", pid is% d\n" , current-> comm, current-> pid);
}
module_init (testDriver1_init);
module_exit (testDriver1_exit);