aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/kmod.h
diff options
context:
space:
mode:
authorJeremy Fitzhardinge <jeremy@xensource.com>2007-07-17 21:37:02 -0400
committerJeremy Fitzhardinge <jeremy@goop.org>2007-07-18 11:47:40 -0400
commit0ab4dc92278a0f3816e486d6350c6652a72e06c8 (patch)
tree84bc321c94ca86a3b5eafa308c8dba9af85a725c /include/linux/kmod.h
parentd84d1cc7647c7e4f77d517e2d87b4a106a0420d9 (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.h44
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
38struct key; 38struct key;
39extern int call_usermodehelper_keys(char *path, char *argv[], char *envp[], 39struct file;
40 struct key *session_keyring, int wait); 40struct subprocess_info;
41
42/* Allocate a subprocess_info structure */
43struct subprocess_info *call_usermodehelper_setup(char *path,
44 char **argv, char **envp);
45
46/* Set various pieces of state into the subprocess_info structure */
47void call_usermodehelper_setkeys(struct subprocess_info *info,
48 struct key *session_keyring);
49int call_usermodehelper_stdinpipe(struct subprocess_info *sub_info,
50 struct file **filp);
51void call_usermodehelper_setcleanup(struct subprocess_info *info,
52 void (*cleanup)(char **argv, char **envp));
53
54/* Actually execute the sub-process */
55int 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 */
59void call_usermodehelper_freeinfo(struct subprocess_info *info);
41 60
42static inline int 61static inline int
43call_usermodehelper(char *path, char **argv, char **envp, int wait) 62call_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
72static inline int
73call_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
48extern void usermodehelper_init(void); 86extern void usermodehelper_init(void);