]>
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> | |
9a575a92 CLG |
7 | #include <linux/nsproxy.h> |
8 | #include <linux/kref.h> | |
aa5a6662 SB |
9 | |
10 | struct pidmap { | |
11 | atomic_t nr_free; | |
12 | void *page; | |
13 | }; | |
14 | ||
15 | #define PIDMAP_ENTRIES ((PID_MAX_LIMIT + 8*PAGE_SIZE - 1)/PAGE_SIZE/8) | |
16 | ||
61a58c6c | 17 | struct pid_namespace { |
9a575a92 CLG |
18 | struct kref kref; |
19 | struct pidmap pidmap[PIDMAP_ENTRIES]; | |
20 | int last_pid; | |
84d73786 | 21 | struct task_struct *child_reaper; |
baf8f0f8 | 22 | struct kmem_cache *pid_cachep; |
faacbfd3 PE |
23 | int level; |
24 | struct pid_namespace *parent; | |
07543f5c PE |
25 | #ifdef CONFIG_PROC_FS |
26 | struct vfsmount *proc_mnt; | |
27 | #endif | |
3fbc9648 SB |
28 | }; |
29 | ||
61a58c6c | 30 | extern struct pid_namespace init_pid_ns; |
3fbc9648 | 31 | |
57d5f66b | 32 | #ifdef CONFIG_PID_NS |
a05f7b15 | 33 | static inline struct pid_namespace *get_pid_ns(struct pid_namespace *ns) |
9a575a92 | 34 | { |
b461cc03 PE |
35 | if (ns != &init_pid_ns) |
36 | kref_get(&ns->kref); | |
a05f7b15 | 37 | return ns; |
9a575a92 CLG |
38 | } |
39 | ||
213dd266 | 40 | extern struct pid_namespace *copy_pid_ns(unsigned long flags, struct pid_namespace *ns); |
9a575a92 | 41 | extern void free_pid_ns(struct kref *kref); |
74bd59bb | 42 | extern void zap_pid_ns_processes(struct pid_namespace *pid_ns); |
9a575a92 CLG |
43 | |
44 | static inline void put_pid_ns(struct pid_namespace *ns) | |
45 | { | |
b461cc03 PE |
46 | if (ns != &init_pid_ns) |
47 | kref_put(&ns->kref, free_pid_ns); | |
9a575a92 CLG |
48 | } |
49 | ||
57d5f66b EB |
50 | #else /* !CONFIG_PID_NS */ |
51 | #include <linux/err.h> | |
52 | ||
53 | static inline struct pid_namespace *get_pid_ns(struct pid_namespace *ns) | |
54 | { | |
55 | return ns; | |
56 | } | |
57 | ||
58 | static inline struct pid_namespace * | |
59 | copy_pid_ns(unsigned long flags, struct pid_namespace *ns) | |
60 | { | |
61 | if (flags & CLONE_NEWPID) | |
62 | ns = ERR_PTR(-EINVAL); | |
63 | return ns; | |
64 | } | |
65 | ||
66 | static inline void put_pid_ns(struct pid_namespace *ns) | |
67 | { | |
68 | } | |
69 | ||
74bd59bb PE |
70 | |
71 | static inline void zap_pid_ns_processes(struct pid_namespace *ns) | |
72 | { | |
73 | BUG(); | |
74 | } | |
57d5f66b EB |
75 | #endif /* CONFIG_PID_NS */ |
76 | ||
2894d650 SB |
77 | static inline struct pid_namespace *task_active_pid_ns(struct task_struct *tsk) |
78 | { | |
79 | return tsk->nsproxy->pid_ns; | |
80 | } | |
81 | ||
88f21d81 | 82 | static inline struct task_struct *task_child_reaper(struct task_struct *tsk) |
84d73786 | 83 | { |
b461cc03 PE |
84 | BUG_ON(tsk != current); |
85 | return tsk->nsproxy->pid_ns->child_reaper; | |
84d73786 SB |
86 | } |
87 | ||
61a58c6c | 88 | #endif /* _LINUX_PID_NS_H */ |