]> err.no Git - linux-2.6/blob - include/linux/pid_namespace.h
pid namespaces: make alloc_pid(), free_pid() and put_pid() work with struct upid
[linux-2.6] / 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/mm.h>
6 #include <linux/threads.h>
7 #include <linux/pid.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 PIDMAP_ENTRIES         ((PID_MAX_LIMIT + 8*PAGE_SIZE - 1)/PAGE_SIZE/8)
17
18 struct pid_namespace {
19         struct kref kref;
20         struct pidmap pidmap[PIDMAP_ENTRIES];
21         int last_pid;
22         struct task_struct *child_reaper;
23         struct kmem_cache *pid_cachep;
24         int level;
25         struct pid_namespace *parent;
26 };
27
28 extern struct pid_namespace init_pid_ns;
29
30 static inline struct pid_namespace *get_pid_ns(struct pid_namespace *ns)
31 {
32         kref_get(&ns->kref);
33         return ns;
34 }
35
36 extern struct pid_namespace *copy_pid_ns(unsigned long flags, struct pid_namespace *ns);
37 extern void free_pid_ns(struct kref *kref);
38
39 static inline void put_pid_ns(struct pid_namespace *ns)
40 {
41         kref_put(&ns->kref, free_pid_ns);
42 }
43
44 static inline struct pid_namespace *task_active_pid_ns(struct task_struct *tsk)
45 {
46         return tsk->nsproxy->pid_ns;
47 }
48
49 static inline struct task_struct *task_child_reaper(struct task_struct *tsk)
50 {
51         return init_pid_ns.child_reaper;
52 }
53
54 #endif /* _LINUX_PID_NS_H */