namespace.h 930 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #ifndef _NAMESPACE_H_
  2. #define _NAMESPACE_H_
  3. #ifdef __KERNEL__
  4. #include <linux/mount.h>
  5. #include <linux/sched.h>
  6. #include <linux/nsproxy.h>
  7. struct namespace {
  8. atomic_t count;
  9. struct vfsmount * root;
  10. struct list_head list;
  11. wait_queue_head_t poll;
  12. int event;
  13. };
  14. extern int copy_namespace(int, struct task_struct *);
  15. extern void __put_namespace(struct namespace *namespace);
  16. extern struct namespace *dup_namespace(struct task_struct *, struct fs_struct *);
  17. static inline void put_namespace(struct namespace *namespace)
  18. {
  19. if (atomic_dec_and_lock(&namespace->count, &vfsmount_lock))
  20. /* releases vfsmount_lock */
  21. __put_namespace(namespace);
  22. }
  23. static inline void exit_namespace(struct task_struct *p)
  24. {
  25. struct namespace *namespace = p->nsproxy->namespace;
  26. if (namespace) {
  27. put_namespace(namespace);
  28. }
  29. }
  30. static inline void get_namespace(struct namespace *namespace)
  31. {
  32. atomic_inc(&namespace->count);
  33. }
  34. #endif
  35. #endif