Sukadev Bhattiprolu | 61a58c6 | 2006-12-08 02:37:58 -0800 | [diff] [blame] | 1 | #ifndef _LINUX_PID_NS_H |
| 2 | #define _LINUX_PID_NS_H |
Sukadev Bhattiprolu | aa5a666 | 2006-10-02 02:17:23 -0700 | [diff] [blame] | 3 | |
| 4 | #include <linux/sched.h> |
| 5 | #include <linux/mm.h> |
| 6 | #include <linux/threads.h> |
Cedric Le Goater | 9a575a9 | 2006-12-08 02:37:59 -0800 | [diff] [blame] | 7 | #include <linux/nsproxy.h> |
| 8 | #include <linux/kref.h> |
Sukadev Bhattiprolu | aa5a666 | 2006-10-02 02:17:23 -0700 | [diff] [blame] | 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 | |
Sukadev Bhattiprolu | 61a58c6 | 2006-12-08 02:37:58 -0800 | [diff] [blame] | 17 | struct pid_namespace { |
Cedric Le Goater | 9a575a9 | 2006-12-08 02:37:59 -0800 | [diff] [blame] | 18 | struct kref kref; |
| 19 | struct pidmap pidmap[PIDMAP_ENTRIES]; |
| 20 | int last_pid; |
Sukadev Bhattiprolu | 84d7378 | 2006-12-08 02:38:01 -0800 | [diff] [blame] | 21 | struct task_struct *child_reaper; |
Pavel Emelianov | baf8f0f | 2007-10-18 23:39:48 -0700 | [diff] [blame] | 22 | struct kmem_cache *pid_cachep; |
Pavel Emelyanov | faacbfd | 2007-10-18 23:40:04 -0700 | [diff] [blame] | 23 | int level; |
| 24 | struct pid_namespace *parent; |
Pavel Emelyanov | 07543f5 | 2007-10-18 23:40:08 -0700 | [diff] [blame] | 25 | #ifdef CONFIG_PROC_FS |
| 26 | struct vfsmount *proc_mnt; |
| 27 | #endif |
Sukadev Bhattiprolu | 3fbc964 | 2006-10-02 02:17:24 -0700 | [diff] [blame] | 28 | }; |
| 29 | |
Sukadev Bhattiprolu | 61a58c6 | 2006-12-08 02:37:58 -0800 | [diff] [blame] | 30 | extern struct pid_namespace init_pid_ns; |
Sukadev Bhattiprolu | 3fbc964 | 2006-10-02 02:17:24 -0700 | [diff] [blame] | 31 | |
Pavel Emelianov | a05f7b1 | 2007-10-18 23:39:47 -0700 | [diff] [blame] | 32 | static inline struct pid_namespace *get_pid_ns(struct pid_namespace *ns) |
Cedric Le Goater | 9a575a9 | 2006-12-08 02:37:59 -0800 | [diff] [blame] | 33 | { |
Pavel Emelyanov | b461cc0 | 2007-10-18 23:40:09 -0700 | [diff] [blame] | 34 | if (ns != &init_pid_ns) |
| 35 | kref_get(&ns->kref); |
Pavel Emelianov | a05f7b1 | 2007-10-18 23:39:47 -0700 | [diff] [blame] | 36 | return ns; |
Cedric Le Goater | 9a575a9 | 2006-12-08 02:37:59 -0800 | [diff] [blame] | 37 | } |
| 38 | |
Eric W. Biederman | 213dd26 | 2007-07-15 23:41:15 -0700 | [diff] [blame] | 39 | extern struct pid_namespace *copy_pid_ns(unsigned long flags, struct pid_namespace *ns); |
Cedric Le Goater | 9a575a9 | 2006-12-08 02:37:59 -0800 | [diff] [blame] | 40 | extern void free_pid_ns(struct kref *kref); |
| 41 | |
| 42 | static inline void put_pid_ns(struct pid_namespace *ns) |
| 43 | { |
Pavel Emelyanov | b461cc0 | 2007-10-18 23:40:09 -0700 | [diff] [blame] | 44 | if (ns != &init_pid_ns) |
| 45 | kref_put(&ns->kref, free_pid_ns); |
Cedric Le Goater | 9a575a9 | 2006-12-08 02:37:59 -0800 | [diff] [blame] | 46 | } |
| 47 | |
Sukadev Bhattiprolu | 2894d650 | 2007-10-18 23:39:49 -0700 | [diff] [blame] | 48 | static inline struct pid_namespace *task_active_pid_ns(struct task_struct *tsk) |
| 49 | { |
| 50 | return tsk->nsproxy->pid_ns; |
| 51 | } |
| 52 | |
Sukadev Bhattiprolu | 88f21d8 | 2007-10-18 23:39:50 -0700 | [diff] [blame] | 53 | static inline struct task_struct *task_child_reaper(struct task_struct *tsk) |
Sukadev Bhattiprolu | 84d7378 | 2006-12-08 02:38:01 -0800 | [diff] [blame] | 54 | { |
Pavel Emelyanov | b461cc0 | 2007-10-18 23:40:09 -0700 | [diff] [blame] | 55 | BUG_ON(tsk != current); |
| 56 | return tsk->nsproxy->pid_ns->child_reaper; |
Sukadev Bhattiprolu | 84d7378 | 2006-12-08 02:38:01 -0800 | [diff] [blame] | 57 | } |
| 58 | |
Sukadev Bhattiprolu | 61a58c6 | 2006-12-08 02:37:58 -0800 | [diff] [blame] | 59 | #endif /* _LINUX_PID_NS_H */ |