at v2.6.24 1.7 kB view raw
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/nsproxy.h> 8#include <linux/kref.h> 9 10struct 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 17struct pid_namespace { 18 struct kref kref; 19 struct pidmap pidmap[PIDMAP_ENTRIES]; 20 int last_pid; 21 struct task_struct *child_reaper; 22 struct kmem_cache *pid_cachep; 23 int level; 24 struct pid_namespace *parent; 25#ifdef CONFIG_PROC_FS 26 struct vfsmount *proc_mnt; 27#endif 28}; 29 30extern struct pid_namespace init_pid_ns; 31 32#ifdef CONFIG_PID_NS 33static inline struct pid_namespace *get_pid_ns(struct pid_namespace *ns) 34{ 35 if (ns != &init_pid_ns) 36 kref_get(&ns->kref); 37 return ns; 38} 39 40extern struct pid_namespace *copy_pid_ns(unsigned long flags, struct pid_namespace *ns); 41extern void free_pid_ns(struct kref *kref); 42 43static inline void put_pid_ns(struct pid_namespace *ns) 44{ 45 if (ns != &init_pid_ns) 46 kref_put(&ns->kref, free_pid_ns); 47} 48 49#else /* !CONFIG_PID_NS */ 50#include <linux/err.h> 51 52static inline struct pid_namespace *get_pid_ns(struct pid_namespace *ns) 53{ 54 return ns; 55} 56 57static inline struct pid_namespace * 58copy_pid_ns(unsigned long flags, struct pid_namespace *ns) 59{ 60 if (flags & CLONE_NEWPID) 61 ns = ERR_PTR(-EINVAL); 62 return ns; 63} 64 65static inline void put_pid_ns(struct pid_namespace *ns) 66{ 67} 68 69#endif /* CONFIG_PID_NS */ 70 71static inline struct pid_namespace *task_active_pid_ns(struct task_struct *tsk) 72{ 73 return tsk->nsproxy->pid_ns; 74} 75 76static inline struct task_struct *task_child_reaper(struct task_struct *tsk) 77{ 78 BUG_ON(tsk != current); 79 return tsk->nsproxy->pid_ns->child_reaper; 80} 81 82#endif /* _LINUX_PID_NS_H */