aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorBoaz Harrosh <bharrosh@panasas.com>2012-05-31 19:26:15 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-05-31 20:49:28 -0400
commit785042f2e275089e22c36b462f6495ce8d91732d (patch)
tree4e847408b4e675c7c616d357ae9b330f7104fbc0 /kernel
parent81ab6e7b26b453a795d46f2616ed0e31d97f05b9 (diff)
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: Boaz 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: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/kmod.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/kernel/kmod.c b/kernel/kmod.c
index 21a0f8e99102..1f596e4de306 100644
--- a/kernel/kmod.c
+++ b/kernel/kmod.c
@@ -478,6 +478,7 @@ static void helper_unlock(void)
478 * structure. This should be passed to call_usermodehelper_exec to 478 * structure. This should be passed to call_usermodehelper_exec to
479 * exec the process and free the structure. 479 * exec the process and free the structure.
480 */ 480 */
481static
481struct subprocess_info *call_usermodehelper_setup(char *path, char **argv, 482struct subprocess_info *call_usermodehelper_setup(char *path, char **argv,
482 char **envp, gfp_t gfp_mask) 483 char **envp, gfp_t gfp_mask)
483{ 484{
@@ -493,7 +494,6 @@ struct subprocess_info *call_usermodehelper_setup(char *path, char **argv,
493 out: 494 out:
494 return sub_info; 495 return sub_info;
495} 496}
496EXPORT_SYMBOL(call_usermodehelper_setup);
497 497
498/** 498/**
499 * call_usermodehelper_setfns - set a cleanup/init function 499 * call_usermodehelper_setfns - set a cleanup/init function
@@ -511,6 +511,7 @@ EXPORT_SYMBOL(call_usermodehelper_setup);
511 * Function must be runnable in either a process context or the 511 * Function must be runnable in either a process context or the
512 * context in which call_usermodehelper_exec is called. 512 * context in which call_usermodehelper_exec is called.
513 */ 513 */
514static
514void call_usermodehelper_setfns(struct subprocess_info *info, 515void call_usermodehelper_setfns(struct subprocess_info *info,
515 int (*init)(struct subprocess_info *info, struct cred *new), 516 int (*init)(struct subprocess_info *info, struct cred *new),
516 void (*cleanup)(struct subprocess_info *info), 517 void (*cleanup)(struct subprocess_info *info),
@@ -520,7 +521,6 @@ void call_usermodehelper_setfns(struct subprocess_info *info,
520 info->init = init; 521 info->init = init;
521 info->data = data; 522 info->data = data;
522} 523}
523EXPORT_SYMBOL(call_usermodehelper_setfns);
524 524
525/** 525/**
526 * call_usermodehelper_exec - start a usermode application 526 * call_usermodehelper_exec - start a usermode application
@@ -534,6 +534,7 @@ EXPORT_SYMBOL(call_usermodehelper_setfns);
534 * asynchronously if wait is not set, and runs as a child of keventd. 534 * asynchronously if wait is not set, and runs as a child of keventd.
535 * (ie. it runs with full root capabilities). 535 * (ie. it runs with full root capabilities).
536 */ 536 */
537static
537int call_usermodehelper_exec(struct subprocess_info *sub_info, int wait) 538int call_usermodehelper_exec(struct subprocess_info *sub_info, int wait)
538{ 539{
539 DECLARE_COMPLETION_ONSTACK(done); 540 DECLARE_COMPLETION_ONSTACK(done);
@@ -575,7 +576,25 @@ unlock:
575 helper_unlock(); 576 helper_unlock();
576 return retval; 577 return retval;
577} 578}
578EXPORT_SYMBOL(call_usermodehelper_exec); 579
580int call_usermodehelper_fns(
581 char *path, char **argv, char **envp, int wait,
582 int (*init)(struct subprocess_info *info, struct cred *new),
583 void (*cleanup)(struct subprocess_info *), void *data)
584{
585 struct subprocess_info *info;
586 gfp_t gfp_mask = (wait == UMH_NO_WAIT) ? GFP_ATOMIC : GFP_KERNEL;
587
588 info = call_usermodehelper_setup(path, argv, envp, gfp_mask);
589
590 if (info == NULL)
591 return -ENOMEM;
592
593 call_usermodehelper_setfns(info, init, cleanup, data);
594
595 return call_usermodehelper_exec(info, wait);
596}
597EXPORT_SYMBOL(call_usermodehelper_fns);
579 598
580static int proc_cap_handler(struct ctl_table *table, int write, 599static int proc_cap_handler(struct ctl_table *table, int write,
581 void __user *buffer, size_t *lenp, loff_t *ppos) 600 void __user *buffer, size_t *lenp, loff_t *ppos)