namespace.h 869 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. wait_queue_head_t poll;
  11. int event;
  12. };
  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_lock(&namespace->count, &vfsmount_lock))
  18. /* releases vfsmount_lock */
  19. __put_namespace(namespace);
  20. }
  21. static inline void exit_namespace(struct task_struct *p)
  22. {
  23. struct namespace *namespace = p->namespace;
  24. if (namespace) {
  25. task_lock(p);
  26. p->namespace = NULL;
  27. task_unlock(p);
  28. put_namespace(namespace);
  29. }
  30. }
  31. static inline void get_namespace(struct namespace *namespace)
  32. {
  33. atomic_inc(&namespace->count);
  34. }
  35. #endif
  36. #endif