Commit 785042f2 authored by Boaz Harrosh's avatar Boaz Harrosh Committed by Linus Torvalds

kmod: move call_usermodehelper_fns() to .c file and unexport all it's helpers

If we move call_usermodehelper_fns() to kmod.c file and EXPORT_SYMBOL it
we can avoid exporting all it's helper functions:
	call_usermodehelper_setup
	call_usermodehelper_setfns
	call_usermodehelper_exec
And make all of them static to kmod.c

Since the optimizer will see all these as a single call site it will
inline them inside call_usermodehelper_fns().  So we loose the call to
_fns but gain 3 calls to the helpers.  (Not that it matters)
Signed-off-by: default avatarBoaz Harrosh <bharrosh@panasas.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 81ab6e7b
...@@ -66,36 +66,10 @@ struct subprocess_info { ...@@ -66,36 +66,10 @@ struct subprocess_info {
void *data; void *data;
}; };
/* Allocate a subprocess_info structure */ extern int
struct subprocess_info *call_usermodehelper_setup(char *path, char **argv,
char **envp, gfp_t gfp_mask);
/* Set various pieces of state into the subprocess_info structure */
void call_usermodehelper_setfns(struct subprocess_info *info,
int (*init)(struct subprocess_info *info, struct cred *new),
void (*cleanup)(struct subprocess_info *info),
void *data);
/* Actually execute the sub-process */
int call_usermodehelper_exec(struct subprocess_info *info, int wait);
static inline int
call_usermodehelper_fns(char *path, char **argv, char **envp, int wait, call_usermodehelper_fns(char *path, char **argv, char **envp, int wait,
int (*init)(struct subprocess_info *info, struct cred *new), int (*init)(struct subprocess_info *info, struct cred *new),
void (*cleanup)(struct subprocess_info *), void *data) void (*cleanup)(struct subprocess_info *), void *data);
{
struct subprocess_info *info;
gfp_t gfp_mask = (wait == UMH_NO_WAIT) ? GFP_ATOMIC : GFP_KERNEL;
info = call_usermodehelper_setup(path, argv, envp, gfp_mask);
if (info == NULL)
return -ENOMEM;
call_usermodehelper_setfns(info, init, cleanup, data);
return call_usermodehelper_exec(info, wait);
}
static inline int static inline int
call_usermodehelper(char *path, char **argv, char **envp, int wait) call_usermodehelper(char *path, char **argv, char **envp, int wait)
......
...@@ -478,6 +478,7 @@ static void helper_unlock(void) ...@@ -478,6 +478,7 @@ static void helper_unlock(void)
* structure. This should be passed to call_usermodehelper_exec to * structure. This should be passed to call_usermodehelper_exec to
* exec the process and free the structure. * exec the process and free the structure.
*/ */
static
struct subprocess_info *call_usermodehelper_setup(char *path, char **argv, struct subprocess_info *call_usermodehelper_setup(char *path, char **argv,
char **envp, gfp_t gfp_mask) char **envp, gfp_t gfp_mask)
{ {
...@@ -493,7 +494,6 @@ struct subprocess_info *call_usermodehelper_setup(char *path, char **argv, ...@@ -493,7 +494,6 @@ struct subprocess_info *call_usermodehelper_setup(char *path, char **argv,
out: out:
return sub_info; return sub_info;
} }
EXPORT_SYMBOL(call_usermodehelper_setup);
/** /**
* call_usermodehelper_setfns - set a cleanup/init function * call_usermodehelper_setfns - set a cleanup/init function
...@@ -511,6 +511,7 @@ EXPORT_SYMBOL(call_usermodehelper_setup); ...@@ -511,6 +511,7 @@ EXPORT_SYMBOL(call_usermodehelper_setup);
* Function must be runnable in either a process context or the * Function must be runnable in either a process context or the
* context in which call_usermodehelper_exec is called. * context in which call_usermodehelper_exec is called.
*/ */
static
void call_usermodehelper_setfns(struct subprocess_info *info, void call_usermodehelper_setfns(struct subprocess_info *info,
int (*init)(struct subprocess_info *info, struct cred *new), int (*init)(struct subprocess_info *info, struct cred *new),
void (*cleanup)(struct subprocess_info *info), void (*cleanup)(struct subprocess_info *info),
...@@ -520,7 +521,6 @@ void call_usermodehelper_setfns(struct subprocess_info *info, ...@@ -520,7 +521,6 @@ void call_usermodehelper_setfns(struct subprocess_info *info,
info->init = init; info->init = init;
info->data = data; info->data = data;
} }
EXPORT_SYMBOL(call_usermodehelper_setfns);
/** /**
* call_usermodehelper_exec - start a usermode application * call_usermodehelper_exec - start a usermode application
...@@ -534,6 +534,7 @@ EXPORT_SYMBOL(call_usermodehelper_setfns); ...@@ -534,6 +534,7 @@ EXPORT_SYMBOL(call_usermodehelper_setfns);
* asynchronously if wait is not set, and runs as a child of keventd. * asynchronously if wait is not set, and runs as a child of keventd.
* (ie. it runs with full root capabilities). * (ie. it runs with full root capabilities).
*/ */
static
int call_usermodehelper_exec(struct subprocess_info *sub_info, int wait) int call_usermodehelper_exec(struct subprocess_info *sub_info, int wait)
{ {
DECLARE_COMPLETION_ONSTACK(done); DECLARE_COMPLETION_ONSTACK(done);
...@@ -575,7 +576,25 @@ int call_usermodehelper_exec(struct subprocess_info *sub_info, int wait) ...@@ -575,7 +576,25 @@ int call_usermodehelper_exec(struct subprocess_info *sub_info, int wait)
helper_unlock(); helper_unlock();
return retval; return retval;
} }
EXPORT_SYMBOL(call_usermodehelper_exec);
int call_usermodehelper_fns(
char *path, char **argv, char **envp, int wait,
int (*init)(struct subprocess_info *info, struct cred *new),
void (*cleanup)(struct subprocess_info *), void *data)
{
struct subprocess_info *info;
gfp_t gfp_mask = (wait == UMH_NO_WAIT) ? GFP_ATOMIC : GFP_KERNEL;
info = call_usermodehelper_setup(path, argv, envp, gfp_mask);
if (info == NULL)
return -ENOMEM;
call_usermodehelper_setfns(info, init, cleanup, data);
return call_usermodehelper_exec(info, wait);
}
EXPORT_SYMBOL(call_usermodehelper_fns);
static int proc_cap_handler(struct ctl_table *table, int write, static int proc_cap_handler(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp, loff_t *ppos) void __user *buffer, size_t *lenp, loff_t *ppos)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment