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> |
| 7 | #include <linux/pid.h> |
Cedric Le Goater | 9a575a9 | 2006-12-08 02:37:59 -0800 | [diff] [blame] | 8 | #include <linux/nsproxy.h> |
| 9 | #include <linux/kref.h> |
Sukadev Bhattiprolu | aa5a666 | 2006-10-02 02:17:23 -0700 | [diff] [blame] | 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 | |
Sukadev Bhattiprolu | 61a58c6 | 2006-12-08 02:37:58 -0800 | [diff] [blame] | 18 | struct pid_namespace { |
Cedric Le Goater | 9a575a9 | 2006-12-08 02:37:59 -0800 | [diff] [blame] | 19 | struct kref kref; |
| 20 | struct pidmap pidmap[PIDMAP_ENTRIES]; |
| 21 | int last_pid; |
Sukadev Bhattiprolu | 84d7378 | 2006-12-08 02:38:01 -0800 | [diff] [blame] | 22 | struct task_struct *child_reaper; |
Sukadev Bhattiprolu | 3fbc964 | 2006-10-02 02:17:24 -0700 | [diff] [blame] | 23 | }; |
| 24 | |
Sukadev Bhattiprolu | 61a58c6 | 2006-12-08 02:37:58 -0800 | [diff] [blame] | 25 | extern struct pid_namespace init_pid_ns; |
Sukadev Bhattiprolu | 3fbc964 | 2006-10-02 02:17:24 -0700 | [diff] [blame] | 26 | |
Cedric Le Goater | 9a575a9 | 2006-12-08 02:37:59 -0800 | [diff] [blame] | 27 | static inline void get_pid_ns(struct pid_namespace *ns) |
| 28 | { |
| 29 | kref_get(&ns->kref); |
| 30 | } |
| 31 | |
Badari Pulavarty | e3222c4 | 2007-05-08 00:25:21 -0700 | [diff] [blame] | 32 | extern struct pid_namespace *copy_pid_ns(int flags, struct pid_namespace *ns); |
Cedric Le Goater | 9a575a9 | 2006-12-08 02:37:59 -0800 | [diff] [blame] | 33 | extern void free_pid_ns(struct kref *kref); |
| 34 | |
| 35 | static inline void put_pid_ns(struct pid_namespace *ns) |
| 36 | { |
| 37 | kref_put(&ns->kref, free_pid_ns); |
| 38 | } |
| 39 | |
Sukadev Bhattiprolu | 84d7378 | 2006-12-08 02:38:01 -0800 | [diff] [blame] | 40 | static inline struct task_struct *child_reaper(struct task_struct *tsk) |
| 41 | { |
Serge E. Hallyn | 0f24528 | 2007-01-30 15:28:23 -0600 | [diff] [blame] | 42 | return init_pid_ns.child_reaper; |
Sukadev Bhattiprolu | 84d7378 | 2006-12-08 02:38:01 -0800 | [diff] [blame] | 43 | } |
| 44 | |
Sukadev Bhattiprolu | 61a58c6 | 2006-12-08 02:37:58 -0800 | [diff] [blame] | 45 | #endif /* _LINUX_PID_NS_H */ |