Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _NAMESPACE_H_ |
| 2 | #define _NAMESPACE_H_ |
| 3 | #ifdef __KERNEL__ |
| 4 | |
| 5 | #include <linux/mount.h> |
| 6 | #include <linux/sched.h> |
| 7 | |
| 8 | struct namespace { |
| 9 | atomic_t count; |
| 10 | struct vfsmount * root; |
| 11 | struct list_head list; |
Al Viro | 5addc5d | 2005-11-07 17:15:49 -0500 | [diff] [blame] | 12 | wait_queue_head_t poll; |
| 13 | int event; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | }; |
| 15 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | extern int copy_namespace(int, struct task_struct *); |
| 17 | extern void __put_namespace(struct namespace *namespace); |
| 18 | |
| 19 | static inline void put_namespace(struct namespace *namespace) |
| 20 | { |
Miklos Szeredi | 1ce88cf | 2005-07-07 17:57:24 -0700 | [diff] [blame] | 21 | if (atomic_dec_and_lock(&namespace->count, &vfsmount_lock)) |
| 22 | /* releases vfsmount_lock */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | __put_namespace(namespace); |
| 24 | } |
| 25 | |
| 26 | static inline void exit_namespace(struct task_struct *p) |
| 27 | { |
| 28 | struct namespace *namespace = p->namespace; |
| 29 | if (namespace) { |
| 30 | task_lock(p); |
| 31 | p->namespace = NULL; |
| 32 | task_unlock(p); |
| 33 | put_namespace(namespace); |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | static inline void get_namespace(struct namespace *namespace) |
| 38 | { |
| 39 | atomic_inc(&namespace->count); |
| 40 | } |
| 41 | |
| 42 | #endif |
| 43 | #endif |