Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / include / linux / pid_namespace.h
1 #ifndef _LINUX_PID_NS_H
2 #define _LINUX_PID_NS_H
3
4 #include <linux/sched.h>
5 #include <linux/bug.h>
6 #include <linux/mm.h>
7 #include <linux/threads.h>
8 #include <linux/nsproxy.h>
9 #include <linux/kref.h>
10
11 struct pidmap {
12 atomic_t nr_free;
13 void *page;
14 };
15
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)
19
20 struct bsd_acct_struct;
21
22 struct pid_namespace {
23 struct kref kref;
24 struct pidmap pidmap[PIDMAP_ENTRIES];
25 int last_pid;
26 unsigned int nr_hashed;
27 struct task_struct *child_reaper;
28 struct kmem_cache *pid_cachep;
29 unsigned int level;
30 struct pid_namespace *parent;
31 #ifdef CONFIG_PROC_FS
32 struct vfsmount *proc_mnt;
33 struct dentry *proc_self;
34 #endif
35 #ifdef CONFIG_BSD_PROCESS_ACCT
36 struct bsd_acct_struct *bacct;
37 #endif
38 struct user_namespace *user_ns;
39 struct work_struct proc_work;
40 kgid_t pid_gid;
41 int hide_pid;
42 int reboot; /* group exit code if this pidns was rebooted */
43 unsigned int proc_inum;
44 };
45
46 extern struct pid_namespace init_pid_ns;
47
48 #define PIDNS_HASH_ADDING (1U << 31)
49
50 #ifdef CONFIG_PID_NS
51 static inline struct pid_namespace *get_pid_ns(struct pid_namespace *ns)
52 {
53 if (ns != &init_pid_ns)
54 kref_get(&ns->kref);
55 return ns;
56 }
57
58 extern struct pid_namespace *copy_pid_ns(unsigned long flags,
59 struct user_namespace *user_ns, struct pid_namespace *ns);
60 extern void zap_pid_ns_processes(struct pid_namespace *pid_ns);
61 extern int reboot_pid_ns(struct pid_namespace *pid_ns, int cmd);
62 extern void put_pid_ns(struct pid_namespace *ns);
63
64 #else /* !CONFIG_PID_NS */
65 #include <linux/err.h>
66
67 static inline struct pid_namespace *get_pid_ns(struct pid_namespace *ns)
68 {
69 return ns;
70 }
71
72 static inline struct pid_namespace *copy_pid_ns(unsigned long flags,
73 struct user_namespace *user_ns, struct pid_namespace *ns)
74 {
75 if (flags & CLONE_NEWPID)
76 ns = ERR_PTR(-EINVAL);
77 return ns;
78 }
79
80 static inline void put_pid_ns(struct pid_namespace *ns)
81 {
82 }
83
84 static inline void zap_pid_ns_processes(struct pid_namespace *ns)
85 {
86 BUG();
87 }
88
89 static inline int reboot_pid_ns(struct pid_namespace *pid_ns, int cmd)
90 {
91 return 0;
92 }
93 #endif /* CONFIG_PID_NS */
94
95 extern struct pid_namespace *task_active_pid_ns(struct task_struct *tsk);
96 void pidhash_init(void);
97 void pidmap_init(void);
98
99 #endif /* _LINUX_PID_NS_H */