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> |
Serge E. Hallyn | 1651e14 | 2006-10-02 02:18:08 -0700 | [diff] [blame] | 7 | #include <linux/nsproxy.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | |
| 9 | struct namespace { |
| 10 | atomic_t count; |
| 11 | struct vfsmount * root; |
| 12 | struct list_head list; |
Al Viro | 5addc5d | 2005-11-07 17:15:49 -0500 | [diff] [blame] | 13 | wait_queue_head_t poll; |
| 14 | int event; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | }; |
| 16 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | extern int copy_namespace(int, struct task_struct *); |
| 18 | extern void __put_namespace(struct namespace *namespace); |
JANAK DESAI | 741a295 | 2006-02-07 12:59:00 -0800 | [diff] [blame] | 19 | extern struct namespace *dup_namespace(struct task_struct *, struct fs_struct *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | |
| 21 | static inline void put_namespace(struct namespace *namespace) |
| 22 | { |
Miklos Szeredi | 1ce88cf | 2005-07-07 17:57:24 -0700 | [diff] [blame] | 23 | if (atomic_dec_and_lock(&namespace->count, &vfsmount_lock)) |
| 24 | /* releases vfsmount_lock */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | __put_namespace(namespace); |
| 26 | } |
| 27 | |
| 28 | static inline void exit_namespace(struct task_struct *p) |
| 29 | { |
Serge E. Hallyn | 1651e14 | 2006-10-02 02:18:08 -0700 | [diff] [blame] | 30 | struct namespace *namespace = p->nsproxy->namespace; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | if (namespace) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | put_namespace(namespace); |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | static inline void get_namespace(struct namespace *namespace) |
| 37 | { |
| 38 | atomic_inc(&namespace->count); |
| 39 | } |
| 40 | |
| 41 | #endif |
| 42 | #endif |