diff options
author | Jeremy Fitzhardinge <jeremy@xensource.com> | 2007-07-17 21:37:02 -0400 |
---|---|---|
committer | Jeremy Fitzhardinge <jeremy@goop.org> | 2007-07-18 11:47:40 -0400 |
commit | 0ab4dc92278a0f3816e486d6350c6652a72e06c8 (patch) | |
tree | 84bc321c94ca86a3b5eafa308c8dba9af85a725c /include/linux/kmod.h | |
parent | d84d1cc7647c7e4f77d517e2d87b4a106a0420d9 (diff) |
usermodehelper: split setup from execution
Rather than having hundreds of variations of call_usermodehelper for
various pieces of usermode state which could be set up, split the
info allocation and initialization from the actual process execution.
This means the general pattern becomes:
info = call_usermodehelper_setup(path, argv, envp); /* basic state */
call_usermodehelper_<SET EXTRA STATE>(info, stuff...); /* extra state */
call_usermodehelper_exec(info, wait); /* run process and free info */
This patch introduces wrappers for all the existing calling styles for
call_usermodehelper_*, but folds their implementations into one.
Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>
Cc: Andi Kleen <ak@suse.de>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: David Howells <dhowells@redhat.com>
Cc: Bj?rn Steinbrink <B.Steinbrink@gmx.de>
Cc: Randy Dunlap <randy.dunlap@oracle.com>
Diffstat (limited to 'include/linux/kmod.h')
-rw-r--r-- | include/linux/kmod.h | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/include/linux/kmod.h b/include/linux/kmod.h index 10f505c8431d..c4cbe59d9c67 100644 --- a/include/linux/kmod.h +++ b/include/linux/kmod.h | |||
@@ -36,13 +36,51 @@ static inline int request_module(const char * name, ...) { return -ENOSYS; } | |||
36 | #define try_then_request_module(x, mod...) ((x) ?: (request_module(mod), (x))) | 36 | #define try_then_request_module(x, mod...) ((x) ?: (request_module(mod), (x))) |
37 | 37 | ||
38 | struct key; | 38 | struct key; |
39 | extern int call_usermodehelper_keys(char *path, char *argv[], char *envp[], | 39 | struct file; |
40 | struct key *session_keyring, int wait); | 40 | struct subprocess_info; |
41 | |||
42 | /* Allocate a subprocess_info structure */ | ||
43 | struct subprocess_info *call_usermodehelper_setup(char *path, | ||
44 | char **argv, char **envp); | ||
45 | |||
46 | /* Set various pieces of state into the subprocess_info structure */ | ||
47 | void call_usermodehelper_setkeys(struct subprocess_info *info, | ||
48 | struct key *session_keyring); | ||
49 | int call_usermodehelper_stdinpipe(struct subprocess_info *sub_info, | ||
50 | struct file **filp); | ||
51 | void call_usermodehelper_setcleanup(struct subprocess_info *info, | ||
52 | void (*cleanup)(char **argv, char **envp)); | ||
53 | |||
54 | /* Actually execute the sub-process */ | ||
55 | int call_usermodehelper_exec(struct subprocess_info *info, int wait); | ||
56 | |||
57 | /* Free the subprocess_info. This is only needed if you're not going | ||
58 | to call call_usermodehelper_exec */ | ||
59 | void call_usermodehelper_freeinfo(struct subprocess_info *info); | ||
41 | 60 | ||
42 | static inline int | 61 | static inline int |
43 | call_usermodehelper(char *path, char **argv, char **envp, int wait) | 62 | call_usermodehelper(char *path, char **argv, char **envp, int wait) |
44 | { | 63 | { |
45 | return call_usermodehelper_keys(path, argv, envp, NULL, wait); | 64 | struct subprocess_info *info; |
65 | |||
66 | info = call_usermodehelper_setup(path, argv, envp); | ||
67 | if (info == NULL) | ||
68 | return -ENOMEM; | ||
69 | return call_usermodehelper_exec(info, wait); | ||
70 | } | ||
71 | |||
72 | static inline int | ||
73 | call_usermodehelper_keys(char *path, char **argv, char **envp, | ||
74 | struct key *session_keyring, int wait) | ||
75 | { | ||
76 | struct subprocess_info *info; | ||
77 | |||
78 | info = call_usermodehelper_setup(path, argv, envp); | ||
79 | if (info == NULL) | ||
80 | return -ENOMEM; | ||
81 | |||
82 | call_usermodehelper_setkeys(info, session_keyring); | ||
83 | return call_usermodehelper_exec(info, wait); | ||
46 | } | 84 | } |
47 | 85 | ||
48 | extern void usermodehelper_init(void); | 86 | extern void usermodehelper_init(void); |