home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / src / linux-headers-2.6.28-15 / include / linux / pid_namespace.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-12-24  |  1.8 KB  |  91 lines

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