namespace.h 811 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 int copy_namespace(int, struct task_struct *);
  13. extern void __put_namespace(struct namespace *namespace);
  14. static inline void put_namespace(struct namespace *namespace)
  15. {
  16. if (atomic_dec_and_test(&namespace->count))
  17. __put_namespace(namespace);
  18. }
  19. static inline void exit_namespace(struct task_struct *p)
  20. {
  21. struct namespace *namespace = p->namespace;
  22. if (namespace) {
  23. task_lock(p);
  24. p->namespace = NULL;
  25. task_unlock(p);
  26. put_namespace(namespace);
  27. }
  28. }
  29. static inline void get_namespace(struct namespace *namespace)
  30. {
  31. atomic_inc(&namespace->count);
  32. }
  33. #endif
  34. #endif