aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2007-02-12 03:53:01 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-12 12:48:32 -0500
commit41487c65bfcce9c8e4d123da1719fcfd8df6d4d0 (patch)
treee2e0e13bc3178c2cff766f1e0165bbbabdb2ed98
parentab521dc0f8e117fd808d3e425216864d60390500 (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>
-rw-r--r--fs/ioprio.c18
-rw-r--r--kernel/capability.c8
-rw-r--r--kernel/sys.c40
3 files changed, 41 insertions, 25 deletions
diff --git a/fs/ioprio.c b/fs/ioprio.c
index 89e8da112a75..10d2c211d18b 100644
--- a/fs/ioprio.c
+++ b/fs/ioprio.c
@@ -60,6 +60,7 @@ asmlinkage long sys_ioprio_set(int which, int who, int ioprio)
60 int data = IOPRIO_PRIO_DATA(ioprio); 60 int data = IOPRIO_PRIO_DATA(ioprio);
61 struct task_struct *p, *g; 61 struct task_struct *p, *g;
62 struct user_struct *user; 62 struct user_struct *user;
63 struct pid *pgrp;
63 int ret; 64 int ret;
64 65
65 switch (class) { 66 switch (class) {
@@ -98,12 +99,14 @@ asmlinkage long sys_ioprio_set(int which, int who, int ioprio)
98 break; 99 break;
99 case IOPRIO_WHO_PGRP: 100 case IOPRIO_WHO_PGRP:
100 if (!who) 101 if (!who)
101 who = process_group(current); 102 pgrp = task_pgrp(current);
102 do_each_task_pid(who, PIDTYPE_PGID, p) { 103 else
104 pgrp = find_pid(who);
105 do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
103 ret = set_task_ioprio(p, ioprio); 106 ret = set_task_ioprio(p, ioprio);
104 if (ret) 107 if (ret)
105 break; 108 break;
106 } while_each_task_pid(who, PIDTYPE_PGID, p); 109 } while_each_pid_task(pgrp, PIDTYPE_PGID, p);
107 break; 110 break;
108 case IOPRIO_WHO_USER: 111 case IOPRIO_WHO_USER:
109 if (!who) 112 if (!who)
@@ -167,6 +170,7 @@ asmlinkage long sys_ioprio_get(int which, int who)
167{ 170{
168 struct task_struct *g, *p; 171 struct task_struct *g, *p;
169 struct user_struct *user; 172 struct user_struct *user;
173 struct pid *pgrp;
170 int ret = -ESRCH; 174 int ret = -ESRCH;
171 int tmpio; 175 int tmpio;
172 176
@@ -182,8 +186,10 @@ asmlinkage long sys_ioprio_get(int which, int who)
182 break; 186 break;
183 case IOPRIO_WHO_PGRP: 187 case IOPRIO_WHO_PGRP:
184 if (!who) 188 if (!who)
185 who = process_group(current); 189 pgrp = task_pgrp(current);
186 do_each_task_pid(who, PIDTYPE_PGID, p) { 190 else
191 pgrp = find_pid(who);
192 do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
187 tmpio = get_task_ioprio(p); 193 tmpio = get_task_ioprio(p);
188 if (tmpio < 0) 194 if (tmpio < 0)
189 continue; 195 continue;
@@ -191,7 +197,7 @@ asmlinkage long sys_ioprio_get(int which, int who)
191 ret = tmpio; 197 ret = tmpio;
192 else 198 else
193 ret = ioprio_best(ret, tmpio); 199 ret = ioprio_best(ret, tmpio);
194 } while_each_task_pid(who, PIDTYPE_PGID, p); 200 } while_each_pid_task(pgrp, PIDTYPE_PGID, p);
195 break; 201 break;
196 case IOPRIO_WHO_USER: 202 case IOPRIO_WHO_USER:
197 if (!who) 203 if (!who)
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 */
95static inline int cap_set_pg(int pgrp, kernel_cap_t *effective, 95static 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