diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2007-02-12 03:53:01 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-02-12 12:48:32 -0500 |
commit | 41487c65bfcce9c8e4d123da1719fcfd8df6d4d0 (patch) | |
tree | e2e0e13bc3178c2cff766f1e0165bbbabdb2ed98 /kernel | |
parent | ab521dc0f8e117fd808d3e425216864d60390500 (diff) |
[PATCH] pid: replace do/while_each_task_pid with do/while_each_pid_task
There isn't any real advantage to this change except that it allows the old
functions to be removed. Which is easier on maintenance and puts the code in
a more uniform style.
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Oleg Nesterov <oleg@tv-sign.ru>
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/capability.c | 8 | ||||
-rw-r--r-- | kernel/sys.c | 40 |
2 files changed, 29 insertions, 19 deletions
diff --git a/kernel/capability.c b/kernel/capability.c index edb845a6e84a..c8d3c7762034 100644 --- a/kernel/capability.c +++ b/kernel/capability.c | |||
@@ -92,15 +92,17 @@ out: | |||
92 | * cap_set_pg - set capabilities for all processes in a given process | 92 | * cap_set_pg - set capabilities for all processes in a given process |
93 | * group. We call this holding task_capability_lock and tasklist_lock. | 93 | * group. We call this holding task_capability_lock and tasklist_lock. |
94 | */ | 94 | */ |
95 | static inline int cap_set_pg(int pgrp, kernel_cap_t *effective, | 95 | static inline int cap_set_pg(int pgrp_nr, kernel_cap_t *effective, |
96 | kernel_cap_t *inheritable, | 96 | kernel_cap_t *inheritable, |
97 | kernel_cap_t *permitted) | 97 | kernel_cap_t *permitted) |
98 | { | 98 | { |
99 | struct task_struct *g, *target; | 99 | struct task_struct *g, *target; |
100 | int ret = -EPERM; | 100 | int ret = -EPERM; |
101 | int found = 0; | 101 | int found = 0; |
102 | struct pid *pgrp; | ||
102 | 103 | ||
103 | do_each_task_pid(pgrp, PIDTYPE_PGID, g) { | 104 | pgrp = find_pid(pgrp_nr); |
105 | do_each_pid_task(pgrp, PIDTYPE_PGID, g) { | ||
104 | target = g; | 106 | target = g; |
105 | while_each_thread(g, target) { | 107 | while_each_thread(g, target) { |
106 | if (!security_capset_check(target, effective, | 108 | if (!security_capset_check(target, effective, |
@@ -113,7 +115,7 @@ static inline int cap_set_pg(int pgrp, kernel_cap_t *effective, | |||
113 | } | 115 | } |
114 | found = 1; | 116 | found = 1; |
115 | } | 117 | } |
116 | } while_each_task_pid(pgrp, PIDTYPE_PGID, g); | 118 | } while_each_pid_task(pgrp, PIDTYPE_PGID, g); |
117 | 119 | ||
118 | if (!found) | 120 | if (!found) |
119 | ret = 0; | 121 | ret = 0; |
diff --git a/kernel/sys.c b/kernel/sys.c index efcf76e0dada..123b165080e6 100644 --- a/kernel/sys.c +++ b/kernel/sys.c | |||
@@ -596,6 +596,7 @@ asmlinkage long sys_setpriority(int which, int who, int niceval) | |||
596 | struct task_struct *g, *p; | 596 | struct task_struct *g, *p; |
597 | struct user_struct *user; | 597 | struct user_struct *user; |
598 | int error = -EINVAL; | 598 | int error = -EINVAL; |
599 | struct pid *pgrp; | ||
599 | 600 | ||
600 | if (which > 2 || which < 0) | 601 | if (which > 2 || which < 0) |
601 | goto out; | 602 | goto out; |
@@ -610,18 +611,21 @@ asmlinkage long sys_setpriority(int which, int who, int niceval) | |||
610 | read_lock(&tasklist_lock); | 611 | read_lock(&tasklist_lock); |
611 | switch (which) { | 612 | switch (which) { |
612 | case PRIO_PROCESS: | 613 | case PRIO_PROCESS: |
613 | if (!who) | 614 | if (who) |
614 | who = current->pid; | 615 | p = find_task_by_pid(who); |
615 | p = find_task_by_pid(who); | 616 | else |
617 | p = current; | ||
616 | if (p) | 618 | if (p) |
617 | error = set_one_prio(p, niceval, error); | 619 | error = set_one_prio(p, niceval, error); |
618 | break; | 620 | break; |
619 | case PRIO_PGRP: | 621 | case PRIO_PGRP: |
620 | if (!who) | 622 | if (who) |
621 | who = process_group(current); | 623 | pgrp = find_pid(who); |
622 | do_each_task_pid(who, PIDTYPE_PGID, p) { | 624 | else |
625 | pgrp = task_pgrp(current); | ||
626 | do_each_pid_task(pgrp, PIDTYPE_PGID, p) { | ||
623 | error = set_one_prio(p, niceval, error); | 627 | error = set_one_prio(p, niceval, error); |
624 | } while_each_task_pid(who, PIDTYPE_PGID, p); | 628 | } while_each_pid_task(pgrp, PIDTYPE_PGID, p); |
625 | break; | 629 | break; |
626 | case PRIO_USER: | 630 | case PRIO_USER: |
627 | user = current->user; | 631 | user = current->user; |
@@ -656,6 +660,7 @@ asmlinkage long sys_getpriority(int which, int who) | |||
656 | struct task_struct *g, *p; | 660 | struct task_struct *g, *p; |
657 | struct user_struct *user; | 661 | struct user_struct *user; |
658 | long niceval, retval = -ESRCH; | 662 | long niceval, retval = -ESRCH; |
663 | struct pid *pgrp; | ||
659 | 664 | ||
660 | if (which > 2 || which < 0) | 665 | if (which > 2 || which < 0) |
661 | return -EINVAL; | 666 | return -EINVAL; |
@@ -663,9 +668,10 @@ asmlinkage long sys_getpriority(int which, int who) | |||
663 | read_lock(&tasklist_lock); | 668 | read_lock(&tasklist_lock); |
664 | switch (which) { | 669 | switch (which) { |
665 | case PRIO_PROCESS: | 670 | case PRIO_PROCESS: |
666 | if (!who) | 671 | if (who) |
667 | who = current->pid; | 672 | p = find_task_by_pid(who); |
668 | p = find_task_by_pid(who); | 673 | else |
674 | p = current; | ||
669 | if (p) { | 675 | if (p) { |
670 | niceval = 20 - task_nice(p); | 676 | niceval = 20 - task_nice(p); |
671 | if (niceval > retval) | 677 | if (niceval > retval) |
@@ -673,13 +679,15 @@ asmlinkage long sys_getpriority(int which, int who) | |||
673 | } | 679 | } |
674 | break; | 680 | break; |
675 | case PRIO_PGRP: | 681 | case PRIO_PGRP: |
676 | if (!who) | 682 | if (who) |
677 | who = process_group(current); | 683 | pgrp = find_pid(who); |
678 | do_each_task_pid(who, PIDTYPE_PGID, p) { | 684 | else |
685 | pgrp = task_pgrp(current); | ||
686 | do_each_pid_task(pgrp, PIDTYPE_PGID, p) { | ||
679 | niceval = 20 - task_nice(p); | 687 | niceval = 20 - task_nice(p); |
680 | if (niceval > retval) | 688 | if (niceval > retval) |
681 | retval = niceval; | 689 | retval = niceval; |
682 | } while_each_task_pid(who, PIDTYPE_PGID, p); | 690 | } while_each_pid_task(pgrp, PIDTYPE_PGID, p); |
683 | break; | 691 | break; |
684 | case PRIO_USER: | 692 | case PRIO_USER: |
685 | user = current->user; | 693 | user = current->user; |
@@ -1388,7 +1396,7 @@ asmlinkage long sys_setpgid(pid_t pid, pid_t pgid) | |||
1388 | 1396 | ||
1389 | if (p->real_parent == group_leader) { | 1397 | if (p->real_parent == group_leader) { |
1390 | err = -EPERM; | 1398 | err = -EPERM; |
1391 | if (process_session(p) != process_session(group_leader)) | 1399 | if (task_session(p) != task_session(group_leader)) |
1392 | goto out; | 1400 | goto out; |
1393 | err = -EACCES; | 1401 | err = -EACCES; |
1394 | if (p->did_exec) | 1402 | if (p->did_exec) |
@@ -1407,7 +1415,7 @@ asmlinkage long sys_setpgid(pid_t pid, pid_t pgid) | |||
1407 | struct task_struct *g = | 1415 | struct task_struct *g = |
1408 | find_task_by_pid_type(PIDTYPE_PGID, pgid); | 1416 | find_task_by_pid_type(PIDTYPE_PGID, pgid); |
1409 | 1417 | ||
1410 | if (!g || process_session(g) != process_session(group_leader)) | 1418 | if (!g || task_session(g) != task_session(group_leader)) |
1411 | goto out; | 1419 | goto out; |
1412 | } | 1420 | } |
1413 | 1421 | ||