]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - kernel/sys.c
[IA64] remove time interpolator
[linux-2.6-omap-h63xx.git] / kernel / sys.c
index cdb7e9457ba6596336b2618282f418bf13626e30..18987c7f6addae96d1049eb9d2dd2a93315975e0 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/prctl.h>
 #include <linux/highuid.h>
 #include <linux/fs.h>
+#include <linux/resource.h>
 #include <linux/kernel.h>
 #include <linux/kexec.h>
 #include <linux/workqueue.h>
 #include <linux/signal.h>
 #include <linux/cn_proc.h>
 #include <linux/getcpu.h>
+#include <linux/task_io_accounting_ops.h>
+#include <linux/seccomp.h>
 
 #include <linux/compat.h>
 #include <linux/syscalls.h>
 #include <linux/kprobes.h>
+#include <linux/user_namespace.h>
 
 #include <asm/uaccess.h>
 #include <asm/io.h>
@@ -658,7 +662,7 @@ asmlinkage long sys_setpriority(int which, int who, int niceval)
        int error = -EINVAL;
        struct pid *pgrp;
 
-       if (which > 2 || which < 0)
+       if (which > PRIO_USER || which < PRIO_PROCESS)
                goto out;
 
        /* normalize: avoid signed division (rounding problems) */
@@ -722,7 +726,7 @@ asmlinkage long sys_getpriority(int which, int who)
        long niceval, retval = -ESRCH;
        struct pid *pgrp;
 
-       if (which > 2 || which < 0)
+       if (which > PRIO_USER || which < PRIO_PROCESS)
                return -EINVAL;
 
        read_lock(&tasklist_lock);
@@ -1076,13 +1080,13 @@ static int set_user(uid_t new_ruid, int dumpclear)
 {
        struct user_struct *new_user;
 
-       new_user = alloc_uid(new_ruid);
+       new_user = alloc_uid(current->nsproxy->user_ns, new_ruid);
        if (!new_user)
                return -EAGAIN;
 
        if (atomic_read(&new_user->processes) >=
                                current->signal->rlim[RLIMIT_NPROC].rlim_cur &&
-                       new_user != &root_user) {
+                       new_user != current->nsproxy->user_ns->root_user) {
                free_uid(new_user);
                return -EAGAIN;
        }
@@ -1486,7 +1490,7 @@ asmlinkage long sys_setpgid(pid_t pid, pid_t pgid)
        if (process_group(p) != pgid) {
                detach_pid(p, PIDTYPE_PGID);
                p->signal->pgrp = pgid;
-               attach_pid(p, PIDTYPE_PGID, pgid);
+               attach_pid(p, PIDTYPE_PGID, find_pid(pgid));
        }
 
        err = 0;
@@ -2082,6 +2086,8 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r)
                        r->ru_nivcsw = p->signal->cnivcsw;
                        r->ru_minflt = p->signal->cmin_flt;
                        r->ru_majflt = p->signal->cmaj_flt;
+                       r->ru_inblock = p->signal->cinblock;
+                       r->ru_oublock = p->signal->coublock;
 
                        if (who == RUSAGE_CHILDREN)
                                break;
@@ -2093,6 +2099,8 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r)
                        r->ru_nivcsw += p->signal->nivcsw;
                        r->ru_minflt += p->signal->min_flt;
                        r->ru_majflt += p->signal->maj_flt;
+                       r->ru_inblock += p->signal->inblock;
+                       r->ru_oublock += p->signal->oublock;
                        t = p;
                        do {
                                utime = cputime_add(utime, t->utime);
@@ -2101,6 +2109,8 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r)
                                r->ru_nivcsw += t->nivcsw;
                                r->ru_minflt += t->min_flt;
                                r->ru_majflt += t->maj_flt;
+                               r->ru_inblock += task_io_get_inblock(t);
+                               r->ru_oublock += task_io_get_oublock(t);
                                t = next_thread(t);
                        } while (t != p);
                        break;
@@ -2233,6 +2243,13 @@ asmlinkage long sys_prctl(int option, unsigned long arg2, unsigned long arg3,
                        error = SET_ENDIAN(current, arg2);
                        break;
 
+               case PR_GET_SECCOMP:
+                       error = prctl_get_seccomp();
+                       break;
+               case PR_SET_SECCOMP:
+                       error = prctl_set_seccomp(arg2);
+                       break;
+
                default:
                        error = -EINVAL;
                        break;
@@ -2269,3 +2286,61 @@ asmlinkage long sys_getcpu(unsigned __user *cpup, unsigned __user *nodep,
        }
        return err ? -EFAULT : 0;
 }
+
+char poweroff_cmd[POWEROFF_CMD_PATH_LEN] = "/sbin/poweroff";
+
+static void argv_cleanup(char **argv, char **envp)
+{
+       argv_free(argv);
+}
+
+/**
+ * orderly_poweroff - Trigger an orderly system poweroff
+ * @force: force poweroff if command execution fails
+ *
+ * This may be called from any context to trigger a system shutdown.
+ * If the orderly shutdown fails, it will force an immediate shutdown.
+ */
+int orderly_poweroff(bool force)
+{
+       int argc;
+       char **argv = argv_split(GFP_ATOMIC, poweroff_cmd, &argc);
+       static char *envp[] = {
+               "HOME=/",
+               "PATH=/sbin:/bin:/usr/sbin:/usr/bin",
+               NULL
+       };
+       int ret = -ENOMEM;
+       struct subprocess_info *info;
+
+       if (argv == NULL) {
+               printk(KERN_WARNING "%s failed to allocate memory for \"%s\"\n",
+                      __func__, poweroff_cmd);
+               goto out;
+       }
+
+       info = call_usermodehelper_setup(argv[0], argv, envp);
+       if (info == NULL) {
+               argv_free(argv);
+               goto out;
+       }
+
+       call_usermodehelper_setcleanup(info, argv_cleanup);
+
+       ret = call_usermodehelper_exec(info, UMH_NO_WAIT);
+
+  out:
+       if (ret && force) {
+               printk(KERN_WARNING "Failed to start orderly shutdown: "
+                      "forcing the issue\n");
+
+               /* I guess this should try to kick off some daemon to
+                  sync and poweroff asap.  Or not even bother syncing
+                  if we're doing an emergency shutdown? */
+               emergency_sync();
+               kernel_power_off();
+       }
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(orderly_poweroff);