diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2014-12-10 21:31:59 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2014-12-10 21:31:59 -0500 |
commit | 707c5960f102f8cdafb9406047b158abc71b391f (patch) | |
tree | 31d195b1c48cefa2d04da7cc801824f87a0a9887 /include/linux | |
parent | ba00410b8131b23edfb0e09f8b6dd26c8eb621fb (diff) | |
parent | 3d3d35b1e94ec918fc0ae670663235bf197d8609 (diff) |
Merge branch 'nsfs' into for-next
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/ipc_namespace.h | 3 | ||||
-rw-r--r-- | include/linux/ns_common.h | 12 | ||||
-rw-r--r-- | include/linux/pid_namespace.h | 3 | ||||
-rw-r--r-- | include/linux/proc_ns.h | 43 | ||||
-rw-r--r-- | include/linux/user_namespace.h | 3 | ||||
-rw-r--r-- | include/linux/utsname.h | 3 |
6 files changed, 43 insertions, 24 deletions
diff --git a/include/linux/ipc_namespace.h b/include/linux/ipc_namespace.h index 35e7eca4e33b..52a640128151 100644 --- a/include/linux/ipc_namespace.h +++ b/include/linux/ipc_namespace.h | |||
@@ -6,6 +6,7 @@ | |||
6 | #include <linux/rwsem.h> | 6 | #include <linux/rwsem.h> |
7 | #include <linux/notifier.h> | 7 | #include <linux/notifier.h> |
8 | #include <linux/nsproxy.h> | 8 | #include <linux/nsproxy.h> |
9 | #include <linux/ns_common.h> | ||
9 | 10 | ||
10 | /* | 11 | /* |
11 | * ipc namespace events | 12 | * ipc namespace events |
@@ -68,7 +69,7 @@ struct ipc_namespace { | |||
68 | /* user_ns which owns the ipc ns */ | 69 | /* user_ns which owns the ipc ns */ |
69 | struct user_namespace *user_ns; | 70 | struct user_namespace *user_ns; |
70 | 71 | ||
71 | unsigned int proc_inum; | 72 | struct ns_common ns; |
72 | }; | 73 | }; |
73 | 74 | ||
74 | extern struct ipc_namespace init_ipc_ns; | 75 | extern struct ipc_namespace init_ipc_ns; |
diff --git a/include/linux/ns_common.h b/include/linux/ns_common.h new file mode 100644 index 000000000000..85a5c8c16be9 --- /dev/null +++ b/include/linux/ns_common.h | |||
@@ -0,0 +1,12 @@ | |||
1 | #ifndef _LINUX_NS_COMMON_H | ||
2 | #define _LINUX_NS_COMMON_H | ||
3 | |||
4 | struct proc_ns_operations; | ||
5 | |||
6 | struct ns_common { | ||
7 | atomic_long_t stashed; | ||
8 | const struct proc_ns_operations *ops; | ||
9 | unsigned int inum; | ||
10 | }; | ||
11 | |||
12 | #endif | ||
diff --git a/include/linux/pid_namespace.h b/include/linux/pid_namespace.h index 1997ffc295a7..b9cf6c51b181 100644 --- a/include/linux/pid_namespace.h +++ b/include/linux/pid_namespace.h | |||
@@ -8,6 +8,7 @@ | |||
8 | #include <linux/threads.h> | 8 | #include <linux/threads.h> |
9 | #include <linux/nsproxy.h> | 9 | #include <linux/nsproxy.h> |
10 | #include <linux/kref.h> | 10 | #include <linux/kref.h> |
11 | #include <linux/ns_common.h> | ||
11 | 12 | ||
12 | struct pidmap { | 13 | struct pidmap { |
13 | atomic_t nr_free; | 14 | atomic_t nr_free; |
@@ -43,7 +44,7 @@ struct pid_namespace { | |||
43 | kgid_t pid_gid; | 44 | kgid_t pid_gid; |
44 | int hide_pid; | 45 | int hide_pid; |
45 | int reboot; /* group exit code if this pidns was rebooted */ | 46 | int reboot; /* group exit code if this pidns was rebooted */ |
46 | unsigned int proc_inum; | 47 | struct ns_common ns; |
47 | }; | 48 | }; |
48 | 49 | ||
49 | extern struct pid_namespace init_pid_ns; | 50 | extern struct pid_namespace init_pid_ns; |
diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h index 34a1e105bef4..42dfc615dbf8 100644 --- a/include/linux/proc_ns.h +++ b/include/linux/proc_ns.h | |||
@@ -4,21 +4,18 @@ | |||
4 | #ifndef _LINUX_PROC_NS_H | 4 | #ifndef _LINUX_PROC_NS_H |
5 | #define _LINUX_PROC_NS_H | 5 | #define _LINUX_PROC_NS_H |
6 | 6 | ||
7 | #include <linux/ns_common.h> | ||
8 | |||
7 | struct pid_namespace; | 9 | struct pid_namespace; |
8 | struct nsproxy; | 10 | struct nsproxy; |
11 | struct path; | ||
9 | 12 | ||
10 | struct proc_ns_operations { | 13 | struct proc_ns_operations { |
11 | const char *name; | 14 | const char *name; |
12 | int type; | 15 | int type; |
13 | void *(*get)(struct task_struct *task); | 16 | struct ns_common *(*get)(struct task_struct *task); |
14 | void (*put)(void *ns); | 17 | void (*put)(struct ns_common *ns); |
15 | int (*install)(struct nsproxy *nsproxy, void *ns); | 18 | int (*install)(struct nsproxy *nsproxy, struct ns_common *ns); |
16 | unsigned int (*inum)(void *ns); | ||
17 | }; | ||
18 | |||
19 | struct proc_ns { | ||
20 | void *ns; | ||
21 | const struct proc_ns_operations *ns_ops; | ||
22 | }; | 19 | }; |
23 | 20 | ||
24 | extern const struct proc_ns_operations netns_operations; | 21 | extern const struct proc_ns_operations netns_operations; |
@@ -43,32 +40,38 @@ enum { | |||
43 | 40 | ||
44 | extern int pid_ns_prepare_proc(struct pid_namespace *ns); | 41 | extern int pid_ns_prepare_proc(struct pid_namespace *ns); |
45 | extern void pid_ns_release_proc(struct pid_namespace *ns); | 42 | extern void pid_ns_release_proc(struct pid_namespace *ns); |
46 | extern struct file *proc_ns_fget(int fd); | ||
47 | extern struct proc_ns *get_proc_ns(struct inode *); | ||
48 | extern int proc_alloc_inum(unsigned int *pino); | 43 | extern int proc_alloc_inum(unsigned int *pino); |
49 | extern void proc_free_inum(unsigned int inum); | 44 | extern void proc_free_inum(unsigned int inum); |
50 | extern bool proc_ns_inode(struct inode *inode); | ||
51 | 45 | ||
52 | #else /* CONFIG_PROC_FS */ | 46 | #else /* CONFIG_PROC_FS */ |
53 | 47 | ||
54 | static inline int pid_ns_prepare_proc(struct pid_namespace *ns) { return 0; } | 48 | static inline int pid_ns_prepare_proc(struct pid_namespace *ns) { return 0; } |
55 | static inline void pid_ns_release_proc(struct pid_namespace *ns) {} | 49 | static inline void pid_ns_release_proc(struct pid_namespace *ns) {} |
56 | 50 | ||
57 | static inline struct file *proc_ns_fget(int fd) | ||
58 | { | ||
59 | return ERR_PTR(-EINVAL); | ||
60 | } | ||
61 | |||
62 | static inline struct proc_ns *get_proc_ns(struct inode *inode) { return NULL; } | ||
63 | |||
64 | static inline int proc_alloc_inum(unsigned int *inum) | 51 | static inline int proc_alloc_inum(unsigned int *inum) |
65 | { | 52 | { |
66 | *inum = 1; | 53 | *inum = 1; |
67 | return 0; | 54 | return 0; |
68 | } | 55 | } |
69 | static inline void proc_free_inum(unsigned int inum) {} | 56 | static inline void proc_free_inum(unsigned int inum) {} |
70 | static inline bool proc_ns_inode(struct inode *inode) { return false; } | ||
71 | 57 | ||
72 | #endif /* CONFIG_PROC_FS */ | 58 | #endif /* CONFIG_PROC_FS */ |
73 | 59 | ||
60 | static inline int ns_alloc_inum(struct ns_common *ns) | ||
61 | { | ||
62 | atomic_long_set(&ns->stashed, 0); | ||
63 | return proc_alloc_inum(&ns->inum); | ||
64 | } | ||
65 | |||
66 | #define ns_free_inum(ns) proc_free_inum((ns)->inum) | ||
67 | |||
68 | extern struct file *proc_ns_fget(int fd); | ||
69 | #define get_proc_ns(inode) ((struct ns_common *)(inode)->i_private) | ||
70 | extern void *ns_get_path(struct path *path, struct task_struct *task, | ||
71 | const struct proc_ns_operations *ns_ops); | ||
72 | |||
73 | extern int ns_get_name(char *buf, size_t size, struct task_struct *task, | ||
74 | const struct proc_ns_operations *ns_ops); | ||
75 | extern void nsfs_init(void); | ||
76 | |||
74 | #endif /* _LINUX_PROC_NS_H */ | 77 | #endif /* _LINUX_PROC_NS_H */ |
diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h index e95372654f09..4cf06c140e21 100644 --- a/include/linux/user_namespace.h +++ b/include/linux/user_namespace.h | |||
@@ -3,6 +3,7 @@ | |||
3 | 3 | ||
4 | #include <linux/kref.h> | 4 | #include <linux/kref.h> |
5 | #include <linux/nsproxy.h> | 5 | #include <linux/nsproxy.h> |
6 | #include <linux/ns_common.h> | ||
6 | #include <linux/sched.h> | 7 | #include <linux/sched.h> |
7 | #include <linux/err.h> | 8 | #include <linux/err.h> |
8 | 9 | ||
@@ -26,7 +27,7 @@ struct user_namespace { | |||
26 | int level; | 27 | int level; |
27 | kuid_t owner; | 28 | kuid_t owner; |
28 | kgid_t group; | 29 | kgid_t group; |
29 | unsigned int proc_inum; | 30 | struct ns_common ns; |
30 | 31 | ||
31 | /* Register of per-UID persistent keyrings for this namespace */ | 32 | /* Register of per-UID persistent keyrings for this namespace */ |
32 | #ifdef CONFIG_PERSISTENT_KEYRINGS | 33 | #ifdef CONFIG_PERSISTENT_KEYRINGS |
diff --git a/include/linux/utsname.h b/include/linux/utsname.h index 239e27733d6c..5093f58ae192 100644 --- a/include/linux/utsname.h +++ b/include/linux/utsname.h | |||
@@ -5,6 +5,7 @@ | |||
5 | #include <linux/sched.h> | 5 | #include <linux/sched.h> |
6 | #include <linux/kref.h> | 6 | #include <linux/kref.h> |
7 | #include <linux/nsproxy.h> | 7 | #include <linux/nsproxy.h> |
8 | #include <linux/ns_common.h> | ||
8 | #include <linux/err.h> | 9 | #include <linux/err.h> |
9 | #include <uapi/linux/utsname.h> | 10 | #include <uapi/linux/utsname.h> |
10 | 11 | ||
@@ -23,7 +24,7 @@ struct uts_namespace { | |||
23 | struct kref kref; | 24 | struct kref kref; |
24 | struct new_utsname name; | 25 | struct new_utsname name; |
25 | struct user_namespace *user_ns; | 26 | struct user_namespace *user_ns; |
26 | unsigned int proc_inum; | 27 | struct ns_common ns; |
27 | }; | 28 | }; |
28 | extern struct uts_namespace init_uts_ns; | 29 | extern struct uts_namespace init_uts_ns; |
29 | 30 | ||