aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/kmod.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/kmod.h')
-rw-r--r--include/linux/kmod.h64
1 files changed, 35 insertions, 29 deletions
diff --git a/include/linux/kmod.h b/include/linux/kmod.h
index facb27fe7de0..6efd7a78de6a 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,19 +46,6 @@ 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
50/* Allocate a subprocess_info structure */
51struct subprocess_info *call_usermodehelper_setup(char *path, char **argv,
52 char **envp, gfp_t gfp_mask);
53
54/* Set various pieces of state into the subprocess_info structure */
55void call_usermodehelper_setkeys(struct subprocess_info *info,
56 struct key *session_keyring);
57int call_usermodehelper_stdinpipe(struct subprocess_info *sub_info,
58 struct file **filp);
59void call_usermodehelper_setcleanup(struct subprocess_info *info,
60 void (*cleanup)(char **argv, char **envp));
61 49
62enum umh_wait { 50enum umh_wait {
63 UMH_NO_WAIT = -1, /* don't wait at all */ 51 UMH_NO_WAIT = -1, /* don't wait at all */
@@ -65,6 +53,29 @@ enum umh_wait {
65 UMH_WAIT_PROC = 1, /* wait for the process to complete */ 53 UMH_WAIT_PROC = 1, /* wait for the process to complete */
66}; 54};
67 55
56struct subprocess_info {
57 struct work_struct work;
58 struct completion *complete;
59 char *path;
60 char **argv;
61 char **envp;
62 enum umh_wait wait;
63 int retval;
64 int (*init)(struct subprocess_info *info);
65 void (*cleanup)(struct subprocess_info *info);
66 void *data;
67};
68
69/* Allocate a subprocess_info structure */
70struct subprocess_info *call_usermodehelper_setup(char *path, char **argv,
71 char **envp, gfp_t gfp_mask);
72
73/* Set various pieces of state into the subprocess_info structure */
74void call_usermodehelper_setfns(struct subprocess_info *info,
75 int (*init)(struct subprocess_info *info),
76 void (*cleanup)(struct subprocess_info *info),
77 void *data);
78
68/* Actually execute the sub-process */ 79/* Actually execute the sub-process */
69int call_usermodehelper_exec(struct subprocess_info *info, enum umh_wait wait); 80int call_usermodehelper_exec(struct subprocess_info *info, enum umh_wait wait);
70 81
@@ -73,38 +84,33 @@ int call_usermodehelper_exec(struct subprocess_info *info, enum umh_wait wait);
73void call_usermodehelper_freeinfo(struct subprocess_info *info); 84void call_usermodehelper_freeinfo(struct subprocess_info *info);
74 85
75static inline int 86static inline int
76call_usermodehelper(char *path, char **argv, char **envp, enum umh_wait wait) 87call_usermodehelper_fns(char *path, char **argv, char **envp,
88 enum umh_wait wait,
89 int (*init)(struct subprocess_info *info),
90 void (*cleanup)(struct subprocess_info *), void *data)
77{ 91{
78 struct subprocess_info *info; 92 struct subprocess_info *info;
79 gfp_t gfp_mask = (wait == UMH_NO_WAIT) ? GFP_ATOMIC : GFP_KERNEL; 93 gfp_t gfp_mask = (wait == UMH_NO_WAIT) ? GFP_ATOMIC : GFP_KERNEL;
80 94
81 info = call_usermodehelper_setup(path, argv, envp, gfp_mask); 95 info = call_usermodehelper_setup(path, argv, envp, gfp_mask);
96
82 if (info == NULL) 97 if (info == NULL)
83 return -ENOMEM; 98 return -ENOMEM;
99
100 call_usermodehelper_setfns(info, init, cleanup, data);
101
84 return call_usermodehelper_exec(info, wait); 102 return call_usermodehelper_exec(info, wait);
85} 103}
86 104
87static inline int 105static inline int
88call_usermodehelper_keys(char *path, char **argv, char **envp, 106call_usermodehelper(char *path, char **argv, char **envp, enum umh_wait wait)
89 struct key *session_keyring, enum umh_wait wait)
90{ 107{
91 struct subprocess_info *info; 108 return call_usermodehelper_fns(path, argv, envp, wait,
92 gfp_t gfp_mask = (wait == UMH_NO_WAIT) ? GFP_ATOMIC : GFP_KERNEL; 109 NULL, NULL, NULL);
93
94 info = call_usermodehelper_setup(path, argv, envp, gfp_mask);
95 if (info == NULL)
96 return -ENOMEM;
97
98 call_usermodehelper_setkeys(info, session_keyring);
99 return call_usermodehelper_exec(info, wait);
100} 110}
101 111
102extern void usermodehelper_init(void); 112extern void usermodehelper_init(void);
103 113
104struct file;
105extern int call_usermodehelper_pipe(char *path, char *argv[], char *envp[],
106 struct file **filp);
107
108extern int usermodehelper_disable(void); 114extern int usermodehelper_disable(void);
109extern void usermodehelper_enable(void); 115extern void usermodehelper_enable(void);
110 116