pid_namespace.c/.h: simplify defines
[platform/adaptation/renesas_rcar/renesas_kernel.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 #endif
34 #ifdef CONFIG_BSD_PROCESS_ACCT
35         struct bsd_acct_struct *bacct;
36 #endif
37         struct user_namespace *user_ns;
38         struct work_struct proc_work;
39         kgid_t pid_gid;
40         int hide_pid;
41         int reboot;     /* group exit code if this pidns was rebooted */
42         unsigned int proc_inum;
43 };
44
45 extern struct pid_namespace init_pid_ns;
46
47 #define PIDNS_HASH_ADDING (1U << 31)
48
49 #ifdef CONFIG_PID_NS
50 static inline struct pid_namespace *get_pid_ns(struct pid_namespace *ns)
51 {
52         if (ns != &init_pid_ns)
53                 kref_get(&ns->kref);
54         return ns;
55 }
56
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);
62
63 #else /* !CONFIG_PID_NS */
64 #include <linux/err.h>
65
66 static inline struct pid_namespace *get_pid_ns(struct pid_namespace *ns)
67 {
68         return ns;
69 }
70
71 static inline struct pid_namespace *copy_pid_ns(unsigned long flags,
72         struct user_namespace *user_ns, struct pid_namespace *ns)
73 {
74         if (flags & CLONE_NEWPID)
75                 ns = ERR_PTR(-EINVAL);
76         return ns;
77 }
78
79 static inline void put_pid_ns(struct pid_namespace *ns)
80 {
81 }
82
83 static inline void zap_pid_ns_processes(struct pid_namespace *ns)
84 {
85         BUG();
86 }
87
88 static inline int reboot_pid_ns(struct pid_namespace *pid_ns, int cmd)
89 {
90         return 0;
91 }
92 #endif /* CONFIG_PID_NS */
93
94 extern struct pid_namespace *task_active_pid_ns(struct task_struct *tsk);
95 void pidhash_init(void);
96 void pidmap_init(void);
97
98 #endif /* _LINUX_PID_NS_H */