Commit | Line | Data |
---|---|---|
61a58c6c SB |
1 | #ifndef _LINUX_PID_NS_H |
2 | #define _LINUX_PID_NS_H | |
aa5a6662 SB |
3 | |
4 | #include <linux/sched.h> | |
5 | #include <linux/mm.h> | |
6 | #include <linux/threads.h> | |
7 | #include <linux/pid.h> | |
9a575a92 CLG |
8 | #include <linux/nsproxy.h> |
9 | #include <linux/kref.h> | |
aa5a6662 SB |
10 | |
11 | struct pidmap { | |
12 | atomic_t nr_free; | |
13 | void *page; | |
14 | }; | |
15 | ||
16 | #define PIDMAP_ENTRIES ((PID_MAX_LIMIT + 8*PAGE_SIZE - 1)/PAGE_SIZE/8) | |
17 | ||
61a58c6c | 18 | struct pid_namespace { |
9a575a92 CLG |
19 | struct kref kref; |
20 | struct pidmap pidmap[PIDMAP_ENTRIES]; | |
21 | int last_pid; | |
84d73786 | 22 | struct task_struct *child_reaper; |
baf8f0f8 | 23 | struct kmem_cache *pid_cachep; |
faacbfd3 PE |
24 | int level; |
25 | struct pid_namespace *parent; | |
07543f5c PE |
26 | #ifdef CONFIG_PROC_FS |
27 | struct vfsmount *proc_mnt; | |
28 | #endif | |
3fbc9648 SB |
29 | }; |
30 | ||
61a58c6c | 31 | extern struct pid_namespace init_pid_ns; |
3fbc9648 | 32 | |
a05f7b15 | 33 | static inline struct pid_namespace *get_pid_ns(struct pid_namespace *ns) |
9a575a92 CLG |
34 | { |
35 | kref_get(&ns->kref); | |
a05f7b15 | 36 | return ns; |
9a575a92 CLG |
37 | } |
38 | ||
213dd266 | 39 | extern struct pid_namespace *copy_pid_ns(unsigned long flags, struct pid_namespace *ns); |
9a575a92 CLG |
40 | extern void free_pid_ns(struct kref *kref); |
41 | ||
42 | static inline void put_pid_ns(struct pid_namespace *ns) | |
43 | { | |
44 | kref_put(&ns->kref, free_pid_ns); | |
45 | } | |
46 | ||
2894d650 SB |
47 | static inline struct pid_namespace *task_active_pid_ns(struct task_struct *tsk) |
48 | { | |
49 | return tsk->nsproxy->pid_ns; | |
50 | } | |
51 | ||
88f21d81 | 52 | static inline struct task_struct *task_child_reaper(struct task_struct *tsk) |
84d73786 | 53 | { |
0f245285 | 54 | return init_pid_ns.child_reaper; |
84d73786 SB |
55 | } |
56 | ||
61a58c6c | 57 | #endif /* _LINUX_PID_NS_H */ |