namespace.h 951 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. extern struct namespace *dup_namespace(struct task_struct *, struct fs_struct *);
  16. static inline void put_namespace(struct namespace *namespace)
  17. {
  18. if (atomic_dec_and_lock(&namespace->count, &vfsmount_lock))
  19. /* releases vfsmount_lock */
  20. __put_namespace(namespace);
  21. }
  22. static inline void exit_namespace(struct task_struct *p)
  23. {
  24. struct namespace *namespace = p->namespace;
  25. if (namespace) {
  26. task_lock(p);
  27. p->namespace = NULL;
  28. task_unlock(p);
  29. put_namespace(namespace);
  30. }
  31. }
  32. static inline void get_namespace(struct namespace *namespace)
  33. {
  34. atomic_inc(&namespace->count);
  35. }
  36. #endif
  37. #endif