diff options
Diffstat (limited to 'include/linux/user_namespace.h')
-rw-r--r-- | include/linux/user_namespace.h | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h new file mode 100644 index 000000000000..92a45867ecfb --- /dev/null +++ b/include/linux/user_namespace.h | |||
@@ -0,0 +1,57 @@ | |||
1 | #ifndef _LINUX_USER_NAMESPACE_H | ||
2 | #define _LINUX_USER_NAMESPACE_H | ||
3 | |||
4 | #include <linux/kref.h> | ||
5 | #include <linux/nsproxy.h> | ||
6 | #include <linux/sched.h> | ||
7 | |||
8 | #define UIDHASH_BITS (CONFIG_BASE_SMALL ? 3 : 8) | ||
9 | #define UIDHASH_SZ (1 << UIDHASH_BITS) | ||
10 | |||
11 | struct user_namespace { | ||
12 | struct kref kref; | ||
13 | struct list_head uidhash_table[UIDHASH_SZ]; | ||
14 | struct user_struct *root_user; | ||
15 | }; | ||
16 | |||
17 | extern struct user_namespace init_user_ns; | ||
18 | |||
19 | #ifdef CONFIG_USER_NS | ||
20 | |||
21 | static inline struct user_namespace *get_user_ns(struct user_namespace *ns) | ||
22 | { | ||
23 | if (ns) | ||
24 | kref_get(&ns->kref); | ||
25 | return ns; | ||
26 | } | ||
27 | |||
28 | extern struct user_namespace *copy_user_ns(int flags, | ||
29 | struct user_namespace *old_ns); | ||
30 | extern void free_user_ns(struct kref *kref); | ||
31 | |||
32 | static inline void put_user_ns(struct user_namespace *ns) | ||
33 | { | ||
34 | if (ns) | ||
35 | kref_put(&ns->kref, free_user_ns); | ||
36 | } | ||
37 | |||
38 | #else | ||
39 | |||
40 | static inline struct user_namespace *get_user_ns(struct user_namespace *ns) | ||
41 | { | ||
42 | return &init_user_ns; | ||
43 | } | ||
44 | |||
45 | static inline struct user_namespace *copy_user_ns(int flags, | ||
46 | struct user_namespace *old_ns) | ||
47 | { | ||
48 | return NULL; | ||
49 | } | ||
50 | |||
51 | static inline void put_user_ns(struct user_namespace *ns) | ||
52 | { | ||
53 | } | ||
54 | |||
55 | #endif | ||
56 | |||
57 | #endif /* _LINUX_USER_H */ | ||