aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/pid_namespace.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/pid_namespace.h')
-rw-r--r--include/linux/pid_namespace.h26
1 files changed, 20 insertions, 6 deletions
diff --git a/include/linux/pid_namespace.h b/include/linux/pid_namespace.h
index b9a17e08ff0f..0135c76c76c6 100644
--- a/include/linux/pid_namespace.h
+++ b/include/linux/pid_namespace.h
@@ -4,7 +4,6 @@
4#include <linux/sched.h> 4#include <linux/sched.h>
5#include <linux/mm.h> 5#include <linux/mm.h>
6#include <linux/threads.h> 6#include <linux/threads.h>
7#include <linux/pid.h>
8#include <linux/nsproxy.h> 7#include <linux/nsproxy.h>
9#include <linux/kref.h> 8#include <linux/kref.h>
10 9
@@ -20,13 +19,21 @@ struct pid_namespace {
20 struct pidmap pidmap[PIDMAP_ENTRIES]; 19 struct pidmap pidmap[PIDMAP_ENTRIES];
21 int last_pid; 20 int last_pid;
22 struct task_struct *child_reaper; 21 struct task_struct *child_reaper;
22 struct kmem_cache *pid_cachep;
23 int level;
24 struct pid_namespace *parent;
25#ifdef CONFIG_PROC_FS
26 struct vfsmount *proc_mnt;
27#endif
23}; 28};
24 29
25extern struct pid_namespace init_pid_ns; 30extern struct pid_namespace init_pid_ns;
26 31
27static inline void get_pid_ns(struct pid_namespace *ns) 32static inline struct pid_namespace *get_pid_ns(struct pid_namespace *ns)
28{ 33{
29 kref_get(&ns->kref); 34 if (ns != &init_pid_ns)
35 kref_get(&ns->kref);
36 return ns;
30} 37}
31 38
32extern struct pid_namespace *copy_pid_ns(unsigned long flags, struct pid_namespace *ns); 39extern struct pid_namespace *copy_pid_ns(unsigned long flags, struct pid_namespace *ns);
@@ -34,12 +41,19 @@ extern void free_pid_ns(struct kref *kref);
34 41
35static inline void put_pid_ns(struct pid_namespace *ns) 42static inline void put_pid_ns(struct pid_namespace *ns)
36{ 43{
37 kref_put(&ns->kref, free_pid_ns); 44 if (ns != &init_pid_ns)
45 kref_put(&ns->kref, free_pid_ns);
38} 46}
39 47
40static inline struct task_struct *child_reaper(struct task_struct *tsk) 48static inline struct pid_namespace *task_active_pid_ns(struct task_struct *tsk)
41{ 49{
42 return init_pid_ns.child_reaper; 50 return tsk->nsproxy->pid_ns;
51}
52
53static inline struct task_struct *task_child_reaper(struct task_struct *tsk)
54{
55 BUG_ON(tsk != current);
56 return tsk->nsproxy->pid_ns->child_reaper;
43} 57}
44 58
45#endif /* _LINUX_PID_NS_H */ 59#endif /* _LINUX_PID_NS_H */