aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/pid.h
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
commit7af5729474b5b8ad385adadab78d6e723e7655a3 (patch)
tree197f8da3e7afd65554f0c0a070eb93036b720fa8 /include/linux/pid.h
parent8ef047aaaeb811247a5639c92e2f2ae1221a28dd (diff)
pid namespaces: helpers to obtain pid numbers
When showing pid to user or getting the pid numerical id for in-kernel use the value of this id may differ depending on the namespace. This set of helpers is used to get the global pid nr, the virtual (i.e. seen by task in its namespace) nr and the nr as it is seen from the specified namespace. 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/linux/pid.h')
-rw-r--r--include/linux/pid.h24
1 files changed, 23 insertions, 1 deletions
diff --git a/include/linux/pid.h b/include/linux/pid.h
index 67470ade3212..c5fee61bfb4f 100644
--- a/include/linux/pid.h
+++ b/include/linux/pid.h
@@ -114,11 +114,33 @@ extern struct pid *find_ge_pid(int nr);
114extern struct pid *alloc_pid(struct pid_namespace *ns); 114extern struct pid *alloc_pid(struct pid_namespace *ns);
115extern void FASTCALL(free_pid(struct pid *pid)); 115extern void FASTCALL(free_pid(struct pid *pid));
116 116
117/*
118 * the helpers to get the pid's id seen from different namespaces
119 *
120 * pid_nr() : global id, i.e. the id seen from the init namespace;
121 * pid_vnr() : virtual id, i.e. the id seen from the namespace this pid
122 * belongs to. this only makes sence when called in the
123 * context of the task that belongs to the same namespace;
124 * pid_nr_ns() : id seen from the ns specified.
125 *
126 * see also task_xid_nr() etc in include/linux/sched.h
127 */
128
117static inline pid_t pid_nr(struct pid *pid) 129static inline pid_t pid_nr(struct pid *pid)
118{ 130{
119 pid_t nr = 0; 131 pid_t nr = 0;
120 if (pid) 132 if (pid)
121 nr = pid->nr; 133 nr = pid->numbers[0].nr;
134 return nr;
135}
136
137pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
138
139static inline pid_t pid_vnr(struct pid *pid)
140{
141 pid_t nr = 0;
142 if (pid)
143 nr = pid->numbers[pid->level].nr;
122 return nr; 144 return nr;
123} 145}
124 146