4e234d8aff43d3318256e8d942b5349dcead9dc6
[linux-2.6.git] / include / linux / namespace.h
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;
12         wait_queue_head_t poll;
13         int event;
14 };
15
16 extern int copy_namespace(int, struct task_struct *);
17 extern void __put_namespace(struct namespace *namespace);
18 extern struct namespace *dup_namespace(struct task_struct *, struct fs_struct *);
19 extern void umount_unused(struct vfsmount *, struct fs_struct *);
20
21 static inline void put_namespace(struct namespace *namespace)
22 {
23         if (atomic_dec_and_lock(&namespace->count, &vfsmount_lock))
24                 /* releases vfsmount_lock */
25                 __put_namespace(namespace);
26 }
27
28 static inline void exit_namespace(struct task_struct *p)
29 {
30         struct namespace *namespace = p->namespace;
31         if (namespace) {
32                 task_lock(p);
33                 p->namespace = NULL;
34                 task_unlock(p);
35                 put_namespace(namespace);
36         }
37 }
38
39 static inline void get_namespace(struct namespace *namespace)
40 {
41         atomic_inc(&namespace->count);
42 }
43
44 #endif
45 #endif