1 #ifndef _LINUX_PID_NS_H
2 #define _LINUX_PID_NS_H
4 #include <linux/sched.h>
7 #include <linux/threads.h>
8 #include <linux/nsproxy.h>
9 #include <linux/kref.h>
16 #define BITS_PER_PAGE (PAGE_SIZE * 8)
17 #define BITS_PER_PAGE_MASK (BITS_PER_PAGE-1)
18 #define PIDMAP_ENTRIES ((PID_MAX_LIMIT+BITS_PER_PAGE-1)/BITS_PER_PAGE)
20 struct bsd_acct_struct;
22 struct pid_namespace {
24 struct pidmap pidmap[PIDMAP_ENTRIES];
26 unsigned int nr_hashed;
27 struct task_struct *child_reaper;
28 struct kmem_cache *pid_cachep;
30 struct pid_namespace *parent;
32 struct vfsmount *proc_mnt;
34 #ifdef CONFIG_BSD_PROCESS_ACCT
35 struct bsd_acct_struct *bacct;
37 struct user_namespace *user_ns;
38 struct work_struct proc_work;
41 int reboot; /* group exit code if this pidns was rebooted */
42 unsigned int proc_inum;
45 extern struct pid_namespace init_pid_ns;
47 #define PIDNS_HASH_ADDING (1U << 31)
50 static inline struct pid_namespace *get_pid_ns(struct pid_namespace *ns)
52 if (ns != &init_pid_ns)
57 extern struct pid_namespace *copy_pid_ns(unsigned long flags,
58 struct user_namespace *user_ns, struct pid_namespace *ns);
59 extern void zap_pid_ns_processes(struct pid_namespace *pid_ns);
60 extern int reboot_pid_ns(struct pid_namespace *pid_ns, int cmd);
61 extern void put_pid_ns(struct pid_namespace *ns);
63 #else /* !CONFIG_PID_NS */
64 #include <linux/err.h>
66 static inline struct pid_namespace *get_pid_ns(struct pid_namespace *ns)
71 static inline struct pid_namespace *copy_pid_ns(unsigned long flags,
72 struct user_namespace *user_ns, struct pid_namespace *ns)
74 if (flags & CLONE_NEWPID)
75 ns = ERR_PTR(-EINVAL);
79 static inline void put_pid_ns(struct pid_namespace *ns)
83 static inline void zap_pid_ns_processes(struct pid_namespace *ns)
88 static inline int reboot_pid_ns(struct pid_namespace *pid_ns, int cmd)
92 #endif /* CONFIG_PID_NS */
94 extern struct pid_namespace *task_active_pid_ns(struct task_struct *tsk);
95 void pidhash_init(void);
96 void pidmap_init(void);
98 #endif /* _LINUX_PID_NS_H */