aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2007-10-19 02:40:06 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-19 14:53:39 -0400
commit198fe21b0a17fe9c68cb519ecc566534b04f122b (patch)
tree690825669858d0f458fc137e42adf77cdf370ea4 /include
parent7af5729474b5b8ad385adadab78d6e723e7655a3 (diff)
pid namespaces: helpers to find the task by its numerical ids
When searching the task by numerical id on may need to find it using global pid (as it is done now in kernel) or by its virtual id, e.g. when sending a signal to a task from one namespace the sender will specify the task's virtual id and we should find the task by this value. [akpm@linux-foundation.org: fix gfs2 linkage] Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Cc: Oleg Nesterov <oleg@tv-sign.ru> Cc: Sukadev Bhattiprolu <sukadev@us.ibm.com> Cc: Paul Menage <menage@google.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/pid.h16
-rw-r--r--include/linux/sched.h31
2 files changed, 43 insertions, 4 deletions
diff --git a/include/linux/pid.h b/include/linux/pid.h
index c5fee61bfb4f..0dc940f4be46 100644
--- a/include/linux/pid.h
+++ b/include/linux/pid.h
@@ -99,17 +99,29 @@ extern void FASTCALL(detach_pid(struct task_struct *task, enum pid_type));
99extern void FASTCALL(transfer_pid(struct task_struct *old, 99extern void FASTCALL(transfer_pid(struct task_struct *old,
100 struct task_struct *new, enum pid_type)); 100 struct task_struct *new, enum pid_type));
101 101
102struct pid_namespace;
103extern struct pid_namespace init_pid_ns;
104
102/* 105/*
103 * look up a PID in the hash table. Must be called with the tasklist_lock 106 * look up a PID in the hash table. Must be called with the tasklist_lock
104 * or rcu_read_lock() held. 107 * or rcu_read_lock() held.
108 *
109 * find_pid_ns() finds the pid in the namespace specified
110 * find_pid() find the pid by its global id, i.e. in the init namespace
111 * find_vpid() finr the pid by its virtual id, i.e. in the current namespace
112 *
113 * see also find_task_by_pid() set in include/linux/sched.h
105 */ 114 */
106extern struct pid *FASTCALL(find_pid(int nr)); 115extern struct pid *FASTCALL(find_pid_ns(int nr, struct pid_namespace *ns));
116
117#define find_vpid(pid) find_pid_ns(pid, current->nsproxy->pid_ns)
118#define find_pid(pid) find_pid_ns(pid, &init_pid_ns)
107 119
108/* 120/*
109 * Lookup a PID in the hash table, and return with it's count elevated. 121 * Lookup a PID in the hash table, and return with it's count elevated.
110 */ 122 */
111extern struct pid *find_get_pid(int nr); 123extern struct pid *find_get_pid(int nr);
112extern struct pid *find_ge_pid(int nr); 124extern struct pid *find_ge_pid(int nr, struct pid_namespace *);
113 125
114extern struct pid *alloc_pid(struct pid_namespace *ns); 126extern struct pid *alloc_pid(struct pid_namespace *ns);
115extern void FASTCALL(free_pid(struct pid *pid)); 127extern void FASTCALL(free_pid(struct pid *pid));
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 77e8cad3b17a..511cc4549f58 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1514,8 +1514,35 @@ extern struct task_struct init_task;
1514 1514
1515extern struct mm_struct init_mm; 1515extern struct mm_struct init_mm;
1516 1516
1517#define find_task_by_pid(nr) find_task_by_pid_type(PIDTYPE_PID, nr) 1517extern struct pid_namespace init_pid_ns;
1518extern struct task_struct *find_task_by_pid_type(int type, int pid); 1518
1519/*
1520 * find a task by one of its numerical ids
1521 *
1522 * find_task_by_pid_type_ns():
1523 * it is the most generic call - it finds a task by all id,
1524 * type and namespace specified
1525 * find_task_by_pid_ns():
1526 * finds a task by its pid in the specified namespace
1527 * find_task_by_pid_type():
1528 * finds a task by its global id with the specified type, e.g.
1529 * by global session id
1530 * find_task_by_pid():
1531 * finds a task by its global pid
1532 *
1533 * see also find_pid() etc in include/linux/pid.h
1534 */
1535
1536extern struct task_struct *find_task_by_pid_type_ns(int type, int pid,
1537 struct pid_namespace *ns);
1538
1539#define find_task_by_pid_ns(nr, ns) \
1540 find_task_by_pid_type_ns(PIDTYPE_PID, nr, ns)
1541#define find_task_by_pid_type(type, nr) \
1542 find_task_by_pid_type_ns(type, nr, &init_pid_ns)
1543#define find_task_by_pid(nr) \
1544 find_task_by_pid_type(PIDTYPE_PID, nr)
1545
1519extern void __set_special_pids(pid_t session, pid_t pgrp); 1546extern void __set_special_pids(pid_t session, pid_t pgrp);
1520 1547
1521/* per-UID process charging. */ 1548/* per-UID process charging. */