aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/linux/kmod.h51
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
46struct key; 47struct key;
47struct file; 48struct file;
48struct subprocess_info; 49
50enum 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
56struct 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 */
51struct subprocess_info *call_usermodehelper_setup(char *path, char **argv, 72struct 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);
57int call_usermodehelper_stdinpipe(struct subprocess_info *sub_info, 78int call_usermodehelper_stdinpipe(struct subprocess_info *sub_info,
58 struct file **filp); 79 struct file **filp);
59void call_usermodehelper_setcleanup(struct subprocess_info *info, 80void 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),
62enum 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 */
69int call_usermodehelper_exec(struct subprocess_info *info, enum umh_wait wait); 86int 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);
73void call_usermodehelper_freeinfo(struct subprocess_info *info); 90void call_usermodehelper_freeinfo(struct subprocess_info *info);
74 91
75static inline int 92static inline int
76call_usermodehelper(char *path, char **argv, char **envp, enum umh_wait wait) 93call_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
87static inline int 111static inline int
112call_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
118static inline int
88call_usermodehelper_keys(char *path, char **argv, char **envp, 119call_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{