blob: d10cb5f75c0621d5e41de188005f61f55c7d3ff0 [file] [log] [blame]
Sukadev Bhattiprolu61a58c62006-12-08 02:37:58 -08001#ifndef _LINUX_PID_NS_H
2#define _LINUX_PID_NS_H
Sukadev Bhattiproluaa5a6662006-10-02 02:17:23 -07003
4#include <linux/sched.h>
5#include <linux/mm.h>
6#include <linux/threads.h>
7#include <linux/pid.h>
Cedric Le Goater9a575a92006-12-08 02:37:59 -08008#include <linux/nsproxy.h>
9#include <linux/kref.h>
Sukadev Bhattiproluaa5a6662006-10-02 02:17:23 -070010
11struct 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 Bhattiprolu61a58c62006-12-08 02:37:58 -080018struct pid_namespace {
Cedric Le Goater9a575a92006-12-08 02:37:59 -080019 struct kref kref;
20 struct pidmap pidmap[PIDMAP_ENTRIES];
21 int last_pid;
Sukadev Bhattiprolu84d73782006-12-08 02:38:01 -080022 struct task_struct *child_reaper;
Pavel Emelianovbaf8f0f2007-10-18 23:39:48 -070023 struct kmem_cache *pid_cachep;
Sukadev Bhattiprolu3fbc9642006-10-02 02:17:24 -070024};
25
Sukadev Bhattiprolu61a58c62006-12-08 02:37:58 -080026extern struct pid_namespace init_pid_ns;
Sukadev Bhattiprolu3fbc9642006-10-02 02:17:24 -070027
Pavel Emelianova05f7b12007-10-18 23:39:47 -070028static inline struct pid_namespace *get_pid_ns(struct pid_namespace *ns)
Cedric Le Goater9a575a92006-12-08 02:37:59 -080029{
30 kref_get(&ns->kref);
Pavel Emelianova05f7b12007-10-18 23:39:47 -070031 return ns;
Cedric Le Goater9a575a92006-12-08 02:37:59 -080032}
33
Eric W. Biederman213dd262007-07-15 23:41:15 -070034extern struct pid_namespace *copy_pid_ns(unsigned long flags, struct pid_namespace *ns);
Cedric Le Goater9a575a92006-12-08 02:37:59 -080035extern void free_pid_ns(struct kref *kref);
36
37static inline void put_pid_ns(struct pid_namespace *ns)
38{
39 kref_put(&ns->kref, free_pid_ns);
40}
41
Sukadev Bhattiprolu2894d6502007-10-18 23:39:49 -070042static inline struct pid_namespace *task_active_pid_ns(struct task_struct *tsk)
43{
44 return tsk->nsproxy->pid_ns;
45}
46
Sukadev Bhattiprolu84d73782006-12-08 02:38:01 -080047static inline struct task_struct *child_reaper(struct task_struct *tsk)
48{
Serge E. Hallyn0f245282007-01-30 15:28:23 -060049 return init_pid_ns.child_reaper;
Sukadev Bhattiprolu84d73782006-12-08 02:38:01 -080050}
51
Sukadev Bhattiprolu61a58c62006-12-08 02:37:58 -080052#endif /* _LINUX_PID_NS_H */