userns: Simplify the user_namespace by making userns->creator a kuid.
[deliverable/linux.git] / include / linux / user_namespace.h
CommitLineData
acce292c
CLG
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>
77ec739d 7#include <linux/err.h>
acce292c 8
acce292c
CLG
9struct user_namespace {
10 struct kref kref;
aeb3ae9d 11 struct user_namespace *parent;
783291e6
EB
12 kuid_t owner;
13 kgid_t group;
acce292c
CLG
14};
15
16extern struct user_namespace init_user_ns;
17
18#ifdef CONFIG_USER_NS
19
20static inline struct user_namespace *get_user_ns(struct user_namespace *ns)
21{
22 if (ns)
23 kref_get(&ns->kref);
24 return ns;
25}
26
18b6e041 27extern int create_user_ns(struct cred *new);
acce292c
CLG
28extern void free_user_ns(struct kref *kref);
29
30static inline void put_user_ns(struct user_namespace *ns)
31{
32 if (ns)
33 kref_put(&ns->kref, free_user_ns);
34}
35
5c1469de
EB
36uid_t user_ns_map_uid(struct user_namespace *to, const struct cred *cred, uid_t uid);
37gid_t user_ns_map_gid(struct user_namespace *to, const struct cred *cred, gid_t gid);
38
acce292c
CLG
39#else
40
41static inline struct user_namespace *get_user_ns(struct user_namespace *ns)
42{
43 return &init_user_ns;
44}
45
18b6e041 46static inline int create_user_ns(struct cred *new)
acce292c 47{
18b6e041 48 return -EINVAL;
acce292c
CLG
49}
50
51static inline void put_user_ns(struct user_namespace *ns)
52{
53}
54
5c1469de
EB
55static inline uid_t user_ns_map_uid(struct user_namespace *to,
56 const struct cred *cred, uid_t uid)
57{
58 return uid;
59}
60static inline gid_t user_ns_map_gid(struct user_namespace *to,
61 const struct cred *cred, gid_t gid)
62{
63 return gid;
64}
65
acce292c
CLG
66#endif
67
68#endif /* _LINUX_USER_H */
This page took 0.705671 seconds and 5 git commands to generate.