]> nv-tegra.nvidia Code Review - linux-2.6.git/blobdiff - include/linux/pid.h
pid namespaces: helpers to obtain pid numbers
[linux-2.6.git] / include / linux / pid.h
index 67470ade32123c022b0b4a44d96eccceadc509da..c5fee61bfb4f9c691eeadbf07b48e741b7483d01 100644 (file)
@@ -114,11 +114,33 @@ extern struct pid *find_ge_pid(int nr);
 extern struct pid *alloc_pid(struct pid_namespace *ns);
 extern void FASTCALL(free_pid(struct pid *pid));
 
+/*
+ * the helpers to get the pid's id seen from different namespaces
+ *
+ * pid_nr()    : global id, i.e. the id seen from the init namespace;
+ * pid_vnr()   : virtual id, i.e. the id seen from the namespace this pid
+ *               belongs to. this only makes sence when called in the
+ *               context of the task that belongs to the same namespace;
+ * pid_nr_ns() : id seen from the ns specified.
+ *
+ * see also task_xid_nr() etc in include/linux/sched.h
+ */
+
 static inline pid_t pid_nr(struct pid *pid)
 {
        pid_t nr = 0;
        if (pid)
-               nr = pid->nr;
+               nr = pid->numbers[0].nr;
+       return nr;
+}
+
+pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
+
+static inline pid_t pid_vnr(struct pid *pid)
+{
+       pid_t nr = 0;
+       if (pid)
+               nr = pid->numbers[pid->level].nr;
        return nr;
 }