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.h65
1 files changed, 36 insertions, 29 deletions
diff --git a/include/linux/kmod.h b/include/linux/kmod.h
index 384ca8bbf1ac..6efd7a78de6a 100644
--- a/include/linux/kmod.h
+++ b/include/linux/kmod.h
@@ -23,10 +23,12 @@
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
29#ifdef CONFIG_MODULES 30#ifdef CONFIG_MODULES
31extern char modprobe_path[]; /* for sysctl */
30/* modprobe exit status on success, -ve on error. Return value 32/* modprobe exit status on success, -ve on error. Return value
31 * usually useless though. */ 33 * usually useless though. */
32extern int __request_module(bool wait, const char *name, ...) \ 34extern int __request_module(bool wait, const char *name, ...) \
@@ -44,19 +46,6 @@ static inline int request_module_nowait(const char *name, ...) { return -ENOSYS;
44 46
45struct key; 47struct key;
46struct file; 48struct file;
47struct subprocess_info;
48
49/* Allocate a subprocess_info structure */
50struct subprocess_info *call_usermodehelper_setup(char *path, char **argv,
51 char **envp, gfp_t gfp_mask);
52
53/* Set various pieces of state into the subprocess_info structure */
54void call_usermodehelper_setkeys(struct subprocess_info *info,
55 struct key *session_keyring);
56int call_usermodehelper_stdinpipe(struct subprocess_info *sub_info,
57 struct file **filp);
58void call_usermodehelper_setcleanup(struct subprocess_info *info,
59 void (*cleanup)(char **argv, char **envp));
60 49
61enum umh_wait { 50enum umh_wait {
62 UMH_NO_WAIT = -1, /* don't wait at all */ 51 UMH_NO_WAIT = -1, /* don't wait at all */
@@ -64,6 +53,29 @@ enum umh_wait {
64 UMH_WAIT_PROC = 1, /* wait for the process to complete */ 53 UMH_WAIT_PROC = 1, /* wait for the process to complete */
65}; 54};
66 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
67/* Actually execute the sub-process */ 79/* Actually execute the sub-process */
68int call_usermodehelper_exec(struct subprocess_info *info, enum umh_wait wait); 80int call_usermodehelper_exec(struct subprocess_info *info, enum umh_wait wait);
69 81
@@ -72,38 +84,33 @@ int call_usermodehelper_exec(struct subprocess_info *info, enum umh_wait wait);
72void call_usermodehelper_freeinfo(struct subprocess_info *info); 84void call_usermodehelper_freeinfo(struct subprocess_info *info);
73 85
74static inline int 86static inline int
75call_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)
76{ 91{
77 struct subprocess_info *info; 92 struct subprocess_info *info;
78 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;
79 94
80 info = call_usermodehelper_setup(path, argv, envp, gfp_mask); 95 info = call_usermodehelper_setup(path, argv, envp, gfp_mask);
96
81 if (info == NULL) 97 if (info == NULL)
82 return -ENOMEM; 98 return -ENOMEM;
99
100 call_usermodehelper_setfns(info, init, cleanup, data);
101
83 return call_usermodehelper_exec(info, wait); 102 return call_usermodehelper_exec(info, wait);
84} 103}
85 104
86static inline int 105static inline int
87call_usermodehelper_keys(char *path, char **argv, char **envp, 106call_usermodehelper(char *path, char **argv, char **envp, enum umh_wait wait)
88 struct key *session_keyring, enum umh_wait wait)
89{ 107{
90 struct subprocess_info *info; 108 return call_usermodehelper_fns(path, argv, envp, wait,
91 gfp_t gfp_mask = (wait == UMH_NO_WAIT) ? GFP_ATOMIC : GFP_KERNEL; 109 NULL, NULL, NULL);
92
93 info = call_usermodehelper_setup(path, argv, envp, gfp_mask);
94 if (info == NULL)
95 return -ENOMEM;
96
97 call_usermodehelper_setkeys(info, session_keyring);
98 return call_usermodehelper_exec(info, wait);
99} 110}
100 111
101extern void usermodehelper_init(void); 112extern void usermodehelper_init(void);
102 113
103struct file;
104extern int call_usermodehelper_pipe(char *path, char *argv[], char *envp[],
105 struct file **filp);
106
107extern int usermodehelper_disable(void); 114extern int usermodehelper_disable(void);
108extern void usermodehelper_enable(void); 115extern void usermodehelper_enable(void);
109 116