[PATCH] BLOCK: Move common FS-specific ioctls to linux/fs.h [try #6]
[pandora-kernel.git] / kernel / kmod.c
index 51a8920..842f801 100644 (file)
@@ -20,7 +20,6 @@
 */
 #define __KERNEL_SYSCALLS__
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/sched.h>
 #include <linux/syscalls.h>
@@ -170,13 +169,15 @@ static int wait_for_helper(void *data)
        sa.sa.sa_handler = SIG_IGN;
        sa.sa.sa_flags = 0;
        siginitset(&sa.sa.sa_mask, sigmask(SIGCHLD));
-       do_sigaction(SIGCHLD, &sa, (struct k_sigaction *)0);
+       do_sigaction(SIGCHLD, &sa, NULL);
        allow_signal(SIGCHLD);
 
        pid = kernel_thread(____call_usermodehelper, sub_info, SIGCHLD);
        if (pid < 0) {
                sub_info->retval = pid;
        } else {
+               int ret;
+
                /*
                 * Normally it is bogus to call wait4() from in-kernel because
                 * wait4() wants to write the exit code to a userspace address.
@@ -186,7 +187,15 @@ static int wait_for_helper(void *data)
                 *
                 * Thus the __user pointer cast is valid here.
                 */
-               sys_wait4(pid, (int __user *) &sub_info->retval, 0, NULL);
+               sys_wait4(pid, (int __user *)&ret, 0, NULL);
+
+               /*
+                * If ret is 0, either ____call_usermodehelper failed and the
+                * real error code is already in sub_info->retval or
+                * sub_info->retval is 0 anyway, so don't mess with it then.
+                */
+               if (ret)
+                       sub_info->retval = ret;
        }
 
        complete(sub_info->complete);
@@ -198,11 +207,12 @@ static void __call_usermodehelper(void *data)
 {
        struct subprocess_info *sub_info = data;
        pid_t pid;
+       int wait = sub_info->wait;
 
        /* CLONE_VFORK: wait until the usermode helper has execve'd
         * successfully We need the data structures to stay around
         * until that is done.  */
-       if (sub_info->wait)
+       if (wait)
                pid = kernel_thread(wait_for_helper, sub_info,
                                    CLONE_FS | CLONE_FILES | SIGCHLD);
        else
@@ -212,7 +222,7 @@ static void __call_usermodehelper(void *data)
        if (pid < 0) {
                sub_info->retval = pid;
                complete(sub_info->complete);
-       } else if (!sub_info->wait)
+       } else if (!wait)
                complete(sub_info->complete);
 }
 
@@ -234,7 +244,7 @@ static void __call_usermodehelper(void *data)
 int call_usermodehelper_keys(char *path, char **argv, char **envp,
                             struct key *session_keyring, int wait)
 {
-       DECLARE_COMPLETION(done);
+       DECLARE_COMPLETION_ONSTACK(done);
        struct subprocess_info sub_info = {
                .complete       = &done,
                .path           = path,