NFS: Kill the obsolete NFS_PARANOIA
[powerpc.git] / kernel / sys.c
index 6e2101d..cdb7e94 100644 (file)
@@ -134,19 +134,39 @@ static int notifier_chain_unregister(struct notifier_block **nl,
        return -ENOENT;
 }
 
+/**
+ * notifier_call_chain - Informs the registered notifiers about an event.
+ *     @nl:            Pointer to head of the blocking notifier chain
+ *     @val:           Value passed unmodified to notifier function
+ *     @v:             Pointer passed unmodified to notifier function
+ *     @nr_to_call:    Number of notifier functions to be called. Don't care
+ *                     value of this parameter is -1.
+ *     @nr_calls:      Records the number of notifications sent. Don't care
+ *                     value of this field is NULL.
+ *     @returns:       notifier_call_chain returns the value returned by the
+ *                     last notifier function called.
+ */
+
 static int __kprobes notifier_call_chain(struct notifier_block **nl,
-               unsigned long val, void *v)
+                                       unsigned long val, void *v,
+                                       int nr_to_call, int *nr_calls)
 {
        int ret = NOTIFY_DONE;
        struct notifier_block *nb, *next_nb;
 
        nb = rcu_dereference(*nl);
-       while (nb) {
+
+       while (nb && nr_to_call) {
                next_nb = rcu_dereference(nb->next);
                ret = nb->notifier_call(nb, val, v);
+
+               if (nr_calls)
+                       (*nr_calls)++;
+
                if ((ret & NOTIFY_STOP_MASK) == NOTIFY_STOP_MASK)
                        break;
                nb = next_nb;
+               nr_to_call--;
        }
        return ret;
 }
@@ -205,36 +225,46 @@ int atomic_notifier_chain_unregister(struct atomic_notifier_head *nh,
 EXPORT_SYMBOL_GPL(atomic_notifier_chain_unregister);
 
 /**
- *     atomic_notifier_call_chain - Call functions in an atomic notifier chain
+ *     __atomic_notifier_call_chain - Call functions in an atomic notifier chain
  *     @nh: Pointer to head of the atomic notifier chain
  *     @val: Value passed unmodified to notifier function
  *     @v: Pointer passed unmodified to notifier function
+ *     @nr_to_call: See the comment for notifier_call_chain.
+ *     @nr_calls: See the comment for notifier_call_chain.
  *
  *     Calls each function in a notifier chain in turn.  The functions
  *     run in an atomic context, so they must not block.
  *     This routine uses RCU to synchronize with changes to the chain.
  *
  *     If the return value of the notifier can be and'ed
- *     with %NOTIFY_STOP_MASK then atomic_notifier_call_chain
+ *     with %NOTIFY_STOP_MASK then atomic_notifier_call_chain()
  *     will return immediately, with the return value of
  *     the notifier function which halted execution.
  *     Otherwise the return value is the return value
  *     of the last notifier function called.
  */
  
-int __kprobes atomic_notifier_call_chain(struct atomic_notifier_head *nh,
-               unsigned long val, void *v)
+int __kprobes __atomic_notifier_call_chain(struct atomic_notifier_head *nh,
+                                       unsigned long val, void *v,
+                                       int nr_to_call, int *nr_calls)
 {
        int ret;
 
        rcu_read_lock();
-       ret = notifier_call_chain(&nh->head, val, v);
+       ret = notifier_call_chain(&nh->head, val, v, nr_to_call, nr_calls);
        rcu_read_unlock();
        return ret;
 }
 
-EXPORT_SYMBOL_GPL(atomic_notifier_call_chain);
+EXPORT_SYMBOL_GPL(__atomic_notifier_call_chain);
 
+int __kprobes atomic_notifier_call_chain(struct atomic_notifier_head *nh,
+               unsigned long val, void *v)
+{
+       return __atomic_notifier_call_chain(nh, val, v, -1, NULL);
+}
+
+EXPORT_SYMBOL_GPL(atomic_notifier_call_chain);
 /*
  *     Blocking notifier chain routines.  All access to the chain is
  *     synchronized by an rwsem.
@@ -304,24 +334,27 @@ int blocking_notifier_chain_unregister(struct blocking_notifier_head *nh,
 EXPORT_SYMBOL_GPL(blocking_notifier_chain_unregister);
 
 /**
- *     blocking_notifier_call_chain - Call functions in a blocking notifier chain
+ *     __blocking_notifier_call_chain - Call functions in a blocking notifier chain
  *     @nh: Pointer to head of the blocking notifier chain
  *     @val: Value passed unmodified to notifier function
  *     @v: Pointer passed unmodified to notifier function
+ *     @nr_to_call: See comment for notifier_call_chain.
+ *     @nr_calls: See comment for notifier_call_chain.
  *
  *     Calls each function in a notifier chain in turn.  The functions
  *     run in a process context, so they are allowed to block.
  *
  *     If the return value of the notifier can be and'ed
- *     with %NOTIFY_STOP_MASK then blocking_notifier_call_chain
+ *     with %NOTIFY_STOP_MASK then blocking_notifier_call_chain()
  *     will return immediately, with the return value of
  *     the notifier function which halted execution.
  *     Otherwise the return value is the return value
  *     of the last notifier function called.
  */
  
-int blocking_notifier_call_chain(struct blocking_notifier_head *nh,
-               unsigned long val, void *v)
+int __blocking_notifier_call_chain(struct blocking_notifier_head *nh,
+                                  unsigned long val, void *v,
+                                  int nr_to_call, int *nr_calls)
 {
        int ret = NOTIFY_DONE;
 
@@ -332,12 +365,19 @@ int blocking_notifier_call_chain(struct blocking_notifier_head *nh,
         */
        if (rcu_dereference(nh->head)) {
                down_read(&nh->rwsem);
-               ret = notifier_call_chain(&nh->head, val, v);
+               ret = notifier_call_chain(&nh->head, val, v, nr_to_call,
+                                       nr_calls);
                up_read(&nh->rwsem);
        }
        return ret;
 }
+EXPORT_SYMBOL_GPL(__blocking_notifier_call_chain);
 
+int blocking_notifier_call_chain(struct blocking_notifier_head *nh,
+               unsigned long val, void *v)
+{
+       return __blocking_notifier_call_chain(nh, val, v, -1, NULL);
+}
 EXPORT_SYMBOL_GPL(blocking_notifier_call_chain);
 
 /*
@@ -383,27 +423,38 @@ int raw_notifier_chain_unregister(struct raw_notifier_head *nh,
 EXPORT_SYMBOL_GPL(raw_notifier_chain_unregister);
 
 /**
- *     raw_notifier_call_chain - Call functions in a raw notifier chain
+ *     __raw_notifier_call_chain - Call functions in a raw notifier chain
  *     @nh: Pointer to head of the raw notifier chain
  *     @val: Value passed unmodified to notifier function
  *     @v: Pointer passed unmodified to notifier function
+ *     @nr_to_call: See comment for notifier_call_chain.
+ *     @nr_calls: See comment for notifier_call_chain
  *
  *     Calls each function in a notifier chain in turn.  The functions
  *     run in an undefined context.
  *     All locking must be provided by the caller.
  *
  *     If the return value of the notifier can be and'ed
- *     with %NOTIFY_STOP_MASK then raw_notifier_call_chain
+ *     with %NOTIFY_STOP_MASK then raw_notifier_call_chain()
  *     will return immediately, with the return value of
  *     the notifier function which halted execution.
  *     Otherwise the return value is the return value
  *     of the last notifier function called.
  */
 
+int __raw_notifier_call_chain(struct raw_notifier_head *nh,
+                             unsigned long val, void *v,
+                             int nr_to_call, int *nr_calls)
+{
+       return notifier_call_chain(&nh->head, val, v, nr_to_call, nr_calls);
+}
+
+EXPORT_SYMBOL_GPL(__raw_notifier_call_chain);
+
 int raw_notifier_call_chain(struct raw_notifier_head *nh,
                unsigned long val, void *v)
 {
-       return notifier_call_chain(&nh->head, val, v);
+       return __raw_notifier_call_chain(nh, val, v, -1, NULL);
 }
 
 EXPORT_SYMBOL_GPL(raw_notifier_call_chain);
@@ -478,34 +529,43 @@ int srcu_notifier_chain_unregister(struct srcu_notifier_head *nh,
 EXPORT_SYMBOL_GPL(srcu_notifier_chain_unregister);
 
 /**
- *     srcu_notifier_call_chain - Call functions in an SRCU notifier chain
+ *     __srcu_notifier_call_chain - Call functions in an SRCU notifier chain
  *     @nh: Pointer to head of the SRCU notifier chain
  *     @val: Value passed unmodified to notifier function
  *     @v: Pointer passed unmodified to notifier function
+ *     @nr_to_call: See comment for notifier_call_chain.
+ *     @nr_calls: See comment for notifier_call_chain
  *
  *     Calls each function in a notifier chain in turn.  The functions
  *     run in a process context, so they are allowed to block.
  *
  *     If the return value of the notifier can be and'ed
- *     with %NOTIFY_STOP_MASK then srcu_notifier_call_chain
+ *     with %NOTIFY_STOP_MASK then srcu_notifier_call_chain()
  *     will return immediately, with the return value of
  *     the notifier function which halted execution.
  *     Otherwise the return value is the return value
  *     of the last notifier function called.
  */
 
-int srcu_notifier_call_chain(struct srcu_notifier_head *nh,
-               unsigned long val, void *v)
+int __srcu_notifier_call_chain(struct srcu_notifier_head *nh,
+                              unsigned long val, void *v,
+                              int nr_to_call, int *nr_calls)
 {
        int ret;
        int idx;
 
        idx = srcu_read_lock(&nh->srcu);
-       ret = notifier_call_chain(&nh->head, val, v);
+       ret = notifier_call_chain(&nh->head, val, v, nr_to_call, nr_calls);
        srcu_read_unlock(&nh->srcu, idx);
        return ret;
 }
+EXPORT_SYMBOL_GPL(__srcu_notifier_call_chain);
 
+int srcu_notifier_call_chain(struct srcu_notifier_head *nh,
+               unsigned long val, void *v)
+{
+       return __srcu_notifier_call_chain(nh, val, v, -1, NULL);
+}
 EXPORT_SYMBOL_GPL(srcu_notifier_call_chain);
 
 /**
@@ -538,7 +598,7 @@ EXPORT_SYMBOL_GPL(srcu_init_notifier_head);
  *     Registers a function with the list of functions
  *     to be called at reboot time.
  *
- *     Currently always returns zero, as blocking_notifier_chain_register
+ *     Currently always returns zero, as blocking_notifier_chain_register()
  *     always returns zero.
  */
  
@@ -596,6 +656,7 @@ asmlinkage long sys_setpriority(int which, int who, int niceval)
        struct task_struct *g, *p;
        struct user_struct *user;
        int error = -EINVAL;
+       struct pid *pgrp;
 
        if (which > 2 || which < 0)
                goto out;
@@ -610,18 +671,21 @@ asmlinkage long sys_setpriority(int which, int who, int niceval)
        read_lock(&tasklist_lock);
        switch (which) {
                case PRIO_PROCESS:
-                       if (!who)
-                               who = current->pid;
-                       p = find_task_by_pid(who);
+                       if (who)
+                               p = find_task_by_pid(who);
+                       else
+                               p = current;
                        if (p)
                                error = set_one_prio(p, niceval, error);
                        break;
                case PRIO_PGRP:
-                       if (!who)
-                               who = process_group(current);
-                       do_each_task_pid(who, PIDTYPE_PGID, p) {
+                       if (who)
+                               pgrp = find_pid(who);
+                       else
+                               pgrp = task_pgrp(current);
+                       do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
                                error = set_one_prio(p, niceval, error);
-                       } while_each_task_pid(who, PIDTYPE_PGID, p);
+                       } while_each_pid_task(pgrp, PIDTYPE_PGID, p);
                        break;
                case PRIO_USER:
                        user = current->user;
@@ -656,6 +720,7 @@ asmlinkage long sys_getpriority(int which, int who)
        struct task_struct *g, *p;
        struct user_struct *user;
        long niceval, retval = -ESRCH;
+       struct pid *pgrp;
 
        if (which > 2 || which < 0)
                return -EINVAL;
@@ -663,9 +728,10 @@ asmlinkage long sys_getpriority(int which, int who)
        read_lock(&tasklist_lock);
        switch (which) {
                case PRIO_PROCESS:
-                       if (!who)
-                               who = current->pid;
-                       p = find_task_by_pid(who);
+                       if (who)
+                               p = find_task_by_pid(who);
+                       else
+                               p = current;
                        if (p) {
                                niceval = 20 - task_nice(p);
                                if (niceval > retval)
@@ -673,13 +739,15 @@ asmlinkage long sys_getpriority(int which, int who)
                        }
                        break;
                case PRIO_PGRP:
-                       if (!who)
-                               who = process_group(current);
-                       do_each_task_pid(who, PIDTYPE_PGID, p) {
+                       if (who)
+                               pgrp = find_pid(who);
+                       else
+                               pgrp = task_pgrp(current);
+                       do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
                                niceval = 20 - task_nice(p);
                                if (niceval > retval)
                                        retval = niceval;
-                       } while_each_task_pid(who, PIDTYPE_PGID, p);
+                       } while_each_pid_task(pgrp, PIDTYPE_PGID, p);
                        break;
                case PRIO_USER:
                        user = current->user;
@@ -873,7 +941,7 @@ asmlinkage long sys_reboot(int magic1, int magic2, unsigned int cmd, void __user
 #ifdef CONFIG_SOFTWARE_SUSPEND
        case LINUX_REBOOT_CMD_SW_SUSPEND:
                {
-                       int ret = software_suspend();
+                       int ret = hibernate();
                        unlock_kernel();
                        return ret;
                }
@@ -1284,7 +1352,7 @@ asmlinkage long sys_setfsuid(uid_t uid)
 }
 
 /*
- * Samma på svenska..
+ * Samma på svenska..
  */
 asmlinkage long sys_setfsgid(gid_t gid)
 {
@@ -1388,7 +1456,7 @@ asmlinkage long sys_setpgid(pid_t pid, pid_t pgid)
 
        if (p->real_parent == group_leader) {
                err = -EPERM;
-               if (process_session(p) != process_session(group_leader))
+               if (task_session(p) != task_session(group_leader))
                        goto out;
                err = -EACCES;
                if (p->did_exec)
@@ -1407,7 +1475,7 @@ asmlinkage long sys_setpgid(pid_t pid, pid_t pgid)
                struct task_struct *g =
                        find_task_by_pid_type(PIDTYPE_PGID, pgid);
 
-               if (!g || process_session(g) != process_session(group_leader))
+               if (!g || task_session(g) != task_session(group_leader))
                        goto out;
        }
 
@@ -1510,7 +1578,6 @@ asmlinkage long sys_setsid(void)
 
        spin_lock(&group_leader->sighand->siglock);
        group_leader->signal->tty = NULL;
-       group_leader->signal->tty_old_pgrp = 0;
        spin_unlock(&group_leader->sighand->siglock);
 
        err = process_group(group_leader);
@@ -1916,6 +1983,16 @@ asmlinkage long sys_setrlimit(unsigned int resource, struct rlimit __user *rlim)
        if (retval)
                return retval;
 
+       if (resource == RLIMIT_CPU && new_rlim.rlim_cur == 0) {
+               /*
+                * The caller is asking for an immediate RLIMIT_CPU
+                * expiry.  But we use the zero value to mean "it was
+                * never set".  So let's cheat and make it one second
+                * instead
+                */
+               new_rlim.rlim_cur = 1;
+       }
+
        task_lock(current->group_leader);
        *old_rlim = new_rlim;
        task_unlock(current->group_leader);
@@ -1937,15 +2014,6 @@ asmlinkage long sys_setrlimit(unsigned int resource, struct rlimit __user *rlim)
                unsigned long rlim_cur = new_rlim.rlim_cur;
                cputime_t cputime;
 
-               if (rlim_cur == 0) {
-                       /*
-                        * The caller is asking for an immediate RLIMIT_CPU
-                        * expiry.  But we use the zero value to mean "it was
-                        * never set".  So let's cheat and make it one second
-                        * instead
-                        */
-                       rlim_cur = 1;
-               }
                cputime = secs_to_cputime(rlim_cur);
                read_lock(&tasklist_lock);
                spin_lock_irq(&current->sighand->siglock);