blob: 6f0f25d64c383dbb556e7ef7fdf058d979b804f5 [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>
7
8struct namespace {
9 atomic_t count;
10 struct vfsmount * root;
11 struct list_head list;
12 struct rw_semaphore sem;
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);
19
20static inline void put_namespace(struct namespace *namespace)
21{
Miklos Szeredi1ce88cf2005-07-07 17:57:24 -070022 if (atomic_dec_and_lock(&namespace->count, &vfsmount_lock))
23 /* releases vfsmount_lock */
Linus Torvalds1da177e2005-04-16 15:20:36 -070024 __put_namespace(namespace);
25}
26
27static inline void exit_namespace(struct task_struct *p)
28{
29 struct namespace *namespace = p->namespace;
30 if (namespace) {
31 task_lock(p);
32 p->namespace = NULL;
33 task_unlock(p);
34 put_namespace(namespace);
35 }
36}
37
38static inline void get_namespace(struct namespace *namespace)
39{
40 atomic_inc(&namespace->count);
41}
42
43#endif
44#endif