pid_namespace.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #ifndef _LINUX_PID_NS_H
  2. #define _LINUX_PID_NS_H
  3. #include <linux/sched.h>
  4. #include <linux/mm.h>
  5. #include <linux/threads.h>
  6. #include <linux/nsproxy.h>
  7. #include <linux/kref.h>
  8. struct pidmap {
  9. atomic_t nr_free;
  10. void *page;
  11. };
  12. #define PIDMAP_ENTRIES ((PID_MAX_LIMIT + 8*PAGE_SIZE - 1)/PAGE_SIZE/8)
  13. struct bsd_acct_struct;
  14. struct pid_namespace {
  15. struct kref kref;
  16. struct pidmap pidmap[PIDMAP_ENTRIES];
  17. int last_pid;
  18. struct task_struct *child_reaper;
  19. struct kmem_cache *pid_cachep;
  20. unsigned int level;
  21. struct pid_namespace *parent;
  22. #ifdef CONFIG_PROC_FS
  23. struct vfsmount *proc_mnt;
  24. #endif
  25. #ifdef CONFIG_BSD_PROCESS_ACCT
  26. struct bsd_acct_struct *bacct;
  27. #endif
  28. };
  29. extern struct pid_namespace init_pid_ns;
  30. #ifdef CONFIG_PID_NS
  31. static inline struct pid_namespace *get_pid_ns(struct pid_namespace *ns)
  32. {
  33. if (ns != &init_pid_ns)
  34. kref_get(&ns->kref);
  35. return ns;
  36. }
  37. extern struct pid_namespace *copy_pid_ns(unsigned long flags, struct pid_namespace *ns);
  38. extern void free_pid_ns(struct kref *kref);
  39. extern void zap_pid_ns_processes(struct pid_namespace *pid_ns);
  40. static inline void put_pid_ns(struct pid_namespace *ns)
  41. {
  42. if (ns != &init_pid_ns)
  43. kref_put(&ns->kref, free_pid_ns);
  44. }
  45. #else /* !CONFIG_PID_NS */
  46. #include <linux/err.h>
  47. static inline struct pid_namespace *get_pid_ns(struct pid_namespace *ns)
  48. {
  49. return ns;
  50. }
  51. static inline struct pid_namespace *
  52. copy_pid_ns(unsigned long flags, struct pid_namespace *ns)
  53. {
  54. if (flags & CLONE_NEWPID)
  55. ns = ERR_PTR(-EINVAL);
  56. return ns;
  57. }
  58. static inline void put_pid_ns(struct pid_namespace *ns)
  59. {
  60. }
  61. static inline void zap_pid_ns_processes(struct pid_namespace *ns)
  62. {
  63. BUG();
  64. }
  65. #endif /* CONFIG_PID_NS */
  66. extern struct pid_namespace *task_active_pid_ns(struct task_struct *tsk);
  67. void pidhash_init(void);
  68. void pidmap_init(void);
  69. #endif /* _LINUX_PID_NS_H */