Cedric Le Goater | acce292 | 2007-07-15 23:40:59 -0700 | [diff] [blame] | 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> |
Serge E. Hallyn | 77ec739 | 2007-07-15 23:41:01 -0700 | [diff] [blame] | 7 | #include <linux/err.h> |
Cedric Le Goater | acce292 | 2007-07-15 23:40:59 -0700 | [diff] [blame] | 8 | |
| 9 | #define UIDHASH_BITS (CONFIG_BASE_SMALL ? 3 : 8) |
| 10 | #define UIDHASH_SZ (1 << UIDHASH_BITS) |
| 11 | |
| 12 | struct user_namespace { |
| 13 | struct kref kref; |
Pavel Emelyanov | 735de22 | 2007-09-18 22:46:44 -0700 | [diff] [blame] | 14 | struct hlist_head uidhash_table[UIDHASH_SZ]; |
Serge Hallyn | 18b6e04 | 2008-10-15 16:38:45 -0500 | [diff] [blame^] | 15 | struct user_struct *creator; |
Cedric Le Goater | acce292 | 2007-07-15 23:40:59 -0700 | [diff] [blame] | 16 | }; |
| 17 | |
| 18 | extern struct user_namespace init_user_ns; |
| 19 | |
| 20 | #ifdef CONFIG_USER_NS |
| 21 | |
| 22 | static inline struct user_namespace *get_user_ns(struct user_namespace *ns) |
| 23 | { |
| 24 | if (ns) |
| 25 | kref_get(&ns->kref); |
| 26 | return ns; |
| 27 | } |
| 28 | |
Serge Hallyn | 18b6e04 | 2008-10-15 16:38:45 -0500 | [diff] [blame^] | 29 | extern int create_user_ns(struct cred *new); |
Cedric Le Goater | acce292 | 2007-07-15 23:40:59 -0700 | [diff] [blame] | 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 | |
Serge Hallyn | 18b6e04 | 2008-10-15 16:38:45 -0500 | [diff] [blame^] | 45 | static inline int create_user_ns(struct cred *new) |
Cedric Le Goater | acce292 | 2007-07-15 23:40:59 -0700 | [diff] [blame] | 46 | { |
Serge Hallyn | 18b6e04 | 2008-10-15 16:38:45 -0500 | [diff] [blame^] | 47 | return -EINVAL; |
Cedric Le Goater | acce292 | 2007-07-15 23:40:59 -0700 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | static inline void put_user_ns(struct user_namespace *ns) |
| 51 | { |
| 52 | } |
| 53 | |
| 54 | #endif |
| 55 | |
| 56 | #endif /* _LINUX_USER_H */ |