blob: d137009f0b2be0feb70efcffba537f899195865d [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _NAMESPACE_H_
2#define _NAMESPACE_H_
3#ifdef __KERNEL__
4
5#include <linux/mount.h>
6#include <linux/sched.h>
Serge E. Hallyn1651e142006-10-02 02:18:08 -07007#include <linux/nsproxy.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008
9struct namespace {
10 atomic_t count;
11 struct vfsmount * root;
12 struct list_head list;
Al Viro5addc5d2005-11-07 17:15:49 -050013 wait_queue_head_t poll;
14 int event;
Linus Torvalds1da177e2005-04-16 15:20:36 -070015};
16
Linus Torvalds1da177e2005-04-16 15:20:36 -070017extern int copy_namespace(int, struct task_struct *);
18extern void __put_namespace(struct namespace *namespace);
JANAK DESAI741a2952006-02-07 12:59:00 -080019extern struct namespace *dup_namespace(struct task_struct *, struct fs_struct *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
21static inline void put_namespace(struct namespace *namespace)
22{
Miklos Szeredi1ce88cf2005-07-07 17:57:24 -070023 if (atomic_dec_and_lock(&namespace->count, &vfsmount_lock))
24 /* releases vfsmount_lock */
Linus Torvalds1da177e2005-04-16 15:20:36 -070025 __put_namespace(namespace);
26}
27
28static inline void exit_namespace(struct task_struct *p)
29{
Serge E. Hallyn1651e142006-10-02 02:18:08 -070030 struct namespace *namespace = p->nsproxy->namespace;
Linus Torvalds1da177e2005-04-16 15:20:36 -070031 if (namespace) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070032 put_namespace(namespace);
33 }
34}
35
36static inline void get_namespace(struct namespace *namespace)
37{
38 atomic_inc(&namespace->count);
39}
40
41#endif
42#endif