namespace.h 855 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #ifndef _NAMESPACE_H_
  2. #define _NAMESPACE_H_
  3. #ifdef __KERNEL__
  4. #include <linux/mount.h>
  5. #include <linux/sched.h>
  6. struct namespace {
  7. atomic_t count;
  8. struct vfsmount * root;
  9. struct list_head list;
  10. struct rw_semaphore sem;
  11. };
  12. extern void umount_tree(struct vfsmount *);
  13. extern int copy_namespace(int, struct task_struct *);
  14. extern void __put_namespace(struct namespace *namespace);
  15. static inline void put_namespace(struct namespace *namespace)
  16. {
  17. if (atomic_dec_and_test(&namespace->count))
  18. __put_namespace(namespace);
  19. }
  20. static inline void exit_namespace(struct task_struct *p)
  21. {
  22. struct namespace *namespace = p->namespace;
  23. if (namespace) {
  24. task_lock(p);
  25. p->namespace = NULL;
  26. task_unlock(p);
  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