diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/kmod.h | 51 |
1 files changed, 41 insertions, 10 deletions
diff --git a/include/linux/kmod.h b/include/linux/kmod.h index facb27fe7de0..f9edf63e90ea 100644 --- a/include/linux/kmod.h +++ b/include/linux/kmod.h | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/stddef.h> | 23 | #include <linux/stddef.h> |
24 | #include <linux/errno.h> | 24 | #include <linux/errno.h> |
25 | #include <linux/compiler.h> | 25 | #include <linux/compiler.h> |
26 | #include <linux/workqueue.h> | ||
26 | 27 | ||
27 | #define KMOD_PATH_LEN 256 | 28 | #define KMOD_PATH_LEN 256 |
28 | 29 | ||
@@ -45,7 +46,27 @@ static inline int request_module_nowait(const char *name, ...) { return -ENOSYS; | |||
45 | 46 | ||
46 | struct key; | 47 | struct key; |
47 | struct file; | 48 | struct file; |
48 | struct subprocess_info; | 49 | |
50 | enum umh_wait { | ||
51 | UMH_NO_WAIT = -1, /* don't wait at all */ | ||
52 | UMH_WAIT_EXEC = 0, /* wait for the exec, but not the process */ | ||
53 | UMH_WAIT_PROC = 1, /* wait for the process to complete */ | ||
54 | }; | ||
55 | |||
56 | struct subprocess_info { | ||
57 | struct work_struct work; | ||
58 | struct completion *complete; | ||
59 | struct cred *cred; | ||
60 | char *path; | ||
61 | char **argv; | ||
62 | char **envp; | ||
63 | enum umh_wait wait; | ||
64 | int retval; | ||
65 | struct file *stdin; | ||
66 | int (*init)(struct subprocess_info *info); | ||
67 | void (*cleanup)(struct subprocess_info *info); | ||
68 | void *data; | ||
69 | }; | ||
49 | 70 | ||
50 | /* Allocate a subprocess_info structure */ | 71 | /* Allocate a subprocess_info structure */ |
51 | struct subprocess_info *call_usermodehelper_setup(char *path, char **argv, | 72 | struct subprocess_info *call_usermodehelper_setup(char *path, char **argv, |
@@ -56,14 +77,10 @@ void call_usermodehelper_setkeys(struct subprocess_info *info, | |||
56 | struct key *session_keyring); | 77 | struct key *session_keyring); |
57 | int call_usermodehelper_stdinpipe(struct subprocess_info *sub_info, | 78 | int call_usermodehelper_stdinpipe(struct subprocess_info *sub_info, |
58 | struct file **filp); | 79 | struct file **filp); |
59 | void call_usermodehelper_setcleanup(struct subprocess_info *info, | 80 | void call_usermodehelper_setfns(struct subprocess_info *info, |
60 | void (*cleanup)(char **argv, char **envp)); | 81 | int (*init)(struct subprocess_info *info), |
61 | 82 | void (*cleanup)(struct subprocess_info *info), | |
62 | enum umh_wait { | 83 | void *data); |
63 | UMH_NO_WAIT = -1, /* don't wait at all */ | ||
64 | UMH_WAIT_EXEC = 0, /* wait for the exec, but not the process */ | ||
65 | UMH_WAIT_PROC = 1, /* wait for the process to complete */ | ||
66 | }; | ||
67 | 84 | ||
68 | /* Actually execute the sub-process */ | 85 | /* Actually execute the sub-process */ |
69 | int call_usermodehelper_exec(struct subprocess_info *info, enum umh_wait wait); | 86 | int call_usermodehelper_exec(struct subprocess_info *info, enum umh_wait wait); |
@@ -73,18 +90,32 @@ int call_usermodehelper_exec(struct subprocess_info *info, enum umh_wait wait); | |||
73 | void call_usermodehelper_freeinfo(struct subprocess_info *info); | 90 | void call_usermodehelper_freeinfo(struct subprocess_info *info); |
74 | 91 | ||
75 | static inline int | 92 | static inline int |
76 | call_usermodehelper(char *path, char **argv, char **envp, enum umh_wait wait) | 93 | call_usermodehelper_fns(char *path, char **argv, char **envp, |
94 | enum umh_wait wait, | ||
95 | int (*init)(struct subprocess_info *info), | ||
96 | void (*cleanup)(struct subprocess_info *), void *data) | ||
77 | { | 97 | { |
78 | struct subprocess_info *info; | 98 | struct subprocess_info *info; |
79 | gfp_t gfp_mask = (wait == UMH_NO_WAIT) ? GFP_ATOMIC : GFP_KERNEL; | 99 | gfp_t gfp_mask = (wait == UMH_NO_WAIT) ? GFP_ATOMIC : GFP_KERNEL; |
80 | 100 | ||
81 | info = call_usermodehelper_setup(path, argv, envp, gfp_mask); | 101 | info = call_usermodehelper_setup(path, argv, envp, gfp_mask); |
102 | |||
82 | if (info == NULL) | 103 | if (info == NULL) |
83 | return -ENOMEM; | 104 | return -ENOMEM; |
105 | |||
106 | call_usermodehelper_setfns(info, init, cleanup, data); | ||
107 | |||
84 | return call_usermodehelper_exec(info, wait); | 108 | return call_usermodehelper_exec(info, wait); |
85 | } | 109 | } |
86 | 110 | ||
87 | static inline int | 111 | static inline int |
112 | call_usermodehelper(char *path, char **argv, char **envp, enum umh_wait wait) | ||
113 | { | ||
114 | return call_usermodehelper_fns(path, argv, envp, wait, | ||
115 | NULL, NULL, NULL); | ||
116 | } | ||
117 | |||
118 | static inline int | ||
88 | call_usermodehelper_keys(char *path, char **argv, char **envp, | 119 | call_usermodehelper_keys(char *path, char **argv, char **envp, |
89 | struct key *session_keyring, enum umh_wait wait) | 120 | struct key *session_keyring, enum umh_wait wait) |
90 | { | 121 | { |