diff options
author | David Howells <dhowells@redhat.com> | 2013-04-11 20:50:06 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-05-01 17:29:39 -0400 |
commit | 0bb80f240520c4148b623161e7856858c021696d (patch) | |
tree | eeb27af589bc12d5864bd2594e5eea59aabe37db /include | |
parent | c3bef7bcaaa7d9f6704fcd81a171c9f0c91a2259 (diff) |
proc: Split the namespace stuff out into linux/proc_ns.h
Split the proc namespace stuff out into linux/proc_ns.h.
Signed-off-by: David Howells <dhowells@redhat.com>
cc: netdev@vger.kernel.org
cc: Serge E. Hallyn <serge.hallyn@ubuntu.com>
cc: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/proc_fs.h | 68 | ||||
-rw-r--r-- | include/linux/proc_ns.h | 74 |
2 files changed, 76 insertions, 66 deletions
diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h index 28a4d7e78803..8f7d8f24141a 100644 --- a/include/linux/proc_fs.h +++ b/include/linux/proc_fs.h | |||
@@ -6,6 +6,7 @@ | |||
6 | #include <linux/spinlock.h> | 6 | #include <linux/spinlock.h> |
7 | #include <linux/magic.h> | 7 | #include <linux/magic.h> |
8 | #include <linux/atomic.h> | 8 | #include <linux/atomic.h> |
9 | #include <linux/proc_ns.h> | ||
9 | 10 | ||
10 | struct net; | 11 | struct net; |
11 | struct completion; | 12 | struct completion; |
@@ -24,18 +25,6 @@ struct mm_struct; | |||
24 | #define PROC_NUMBUF 13 | 25 | #define PROC_NUMBUF 13 |
25 | 26 | ||
26 | /* | 27 | /* |
27 | * We always define these enumerators | ||
28 | */ | ||
29 | |||
30 | enum { | ||
31 | PROC_ROOT_INO = 1, | ||
32 | PROC_IPC_INIT_INO = 0xEFFFFFFFU, | ||
33 | PROC_UTS_INIT_INO = 0xEFFFFFFEU, | ||
34 | PROC_USER_INIT_INO = 0xEFFFFFFDU, | ||
35 | PROC_PID_INIT_INO = 0xEFFFFFFCU, | ||
36 | }; | ||
37 | |||
38 | /* | ||
39 | * This is not completely implemented yet. The idea is to | 28 | * This is not completely implemented yet. The idea is to |
40 | * create an in-memory tree (like the actual /proc filesystem | 29 | * create an in-memory tree (like the actual /proc filesystem |
41 | * tree) of these proc_dir_entries, so that we can dynamically | 30 | * tree) of these proc_dir_entries, so that we can dynamically |
@@ -81,10 +70,6 @@ struct proc_dir_entry *proc_create_data(const char *name, umode_t mode, | |||
81 | extern void remove_proc_entry(const char *name, struct proc_dir_entry *parent); | 70 | extern void remove_proc_entry(const char *name, struct proc_dir_entry *parent); |
82 | extern int remove_proc_subtree(const char *name, struct proc_dir_entry *parent); | 71 | extern int remove_proc_subtree(const char *name, struct proc_dir_entry *parent); |
83 | 72 | ||
84 | struct pid_namespace; | ||
85 | |||
86 | extern int pid_ns_prepare_proc(struct pid_namespace *ns); | ||
87 | extern void pid_ns_release_proc(struct pid_namespace *ns); | ||
88 | 73 | ||
89 | /* | 74 | /* |
90 | * proc_tty.c | 75 | * proc_tty.c |
@@ -132,12 +117,6 @@ extern struct proc_dir_entry *proc_net_mkdir(struct net *net, const char *name, | |||
132 | 117 | ||
133 | extern void proc_set_size(struct proc_dir_entry *, loff_t); | 118 | extern void proc_set_size(struct proc_dir_entry *, loff_t); |
134 | extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t); | 119 | extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t); |
135 | |||
136 | extern struct file *proc_ns_fget(int fd); | ||
137 | extern bool proc_ns_inode(struct inode *inode); | ||
138 | |||
139 | extern int proc_alloc_inum(unsigned int *pino); | ||
140 | extern void proc_free_inum(unsigned int inum); | ||
141 | #else | 120 | #else |
142 | 121 | ||
143 | static inline void proc_flush_task(struct task_struct *task) | 122 | static inline void proc_flush_task(struct task_struct *task) |
@@ -168,50 +147,8 @@ struct tty_driver; | |||
168 | static inline void proc_tty_register_driver(struct tty_driver *driver) {}; | 147 | static inline void proc_tty_register_driver(struct tty_driver *driver) {}; |
169 | static inline void proc_tty_unregister_driver(struct tty_driver *driver) {}; | 148 | static inline void proc_tty_unregister_driver(struct tty_driver *driver) {}; |
170 | 149 | ||
171 | static inline int pid_ns_prepare_proc(struct pid_namespace *ns) | ||
172 | { | ||
173 | return 0; | ||
174 | } | ||
175 | |||
176 | static inline void pid_ns_release_proc(struct pid_namespace *ns) | ||
177 | { | ||
178 | } | ||
179 | |||
180 | static inline struct file *proc_ns_fget(int fd) | ||
181 | { | ||
182 | return ERR_PTR(-EINVAL); | ||
183 | } | ||
184 | |||
185 | static inline bool proc_ns_inode(struct inode *inode) | ||
186 | { | ||
187 | return false; | ||
188 | } | ||
189 | |||
190 | static inline int proc_alloc_inum(unsigned int *inum) | ||
191 | { | ||
192 | *inum = 1; | ||
193 | return 0; | ||
194 | } | ||
195 | static inline void proc_free_inum(unsigned int inum) | ||
196 | { | ||
197 | } | ||
198 | #endif /* CONFIG_PROC_FS */ | 150 | #endif /* CONFIG_PROC_FS */ |
199 | 151 | ||
200 | struct nsproxy; | ||
201 | struct proc_ns_operations { | ||
202 | const char *name; | ||
203 | int type; | ||
204 | void *(*get)(struct task_struct *task); | ||
205 | void (*put)(void *ns); | ||
206 | int (*install)(struct nsproxy *nsproxy, void *ns); | ||
207 | unsigned int (*inum)(void *ns); | ||
208 | }; | ||
209 | extern const struct proc_ns_operations netns_operations; | ||
210 | extern const struct proc_ns_operations utsns_operations; | ||
211 | extern const struct proc_ns_operations ipcns_operations; | ||
212 | extern const struct proc_ns_operations pidns_operations; | ||
213 | extern const struct proc_ns_operations userns_operations; | ||
214 | extern const struct proc_ns_operations mntns_operations; | ||
215 | 152 | ||
216 | union proc_op { | 153 | union proc_op { |
217 | int (*proc_get_link)(struct dentry *, struct path *); | 154 | int (*proc_get_link)(struct dentry *, struct path *); |
@@ -231,8 +168,7 @@ struct proc_inode { | |||
231 | struct proc_dir_entry *pde; | 168 | struct proc_dir_entry *pde; |
232 | struct ctl_table_header *sysctl; | 169 | struct ctl_table_header *sysctl; |
233 | struct ctl_table *sysctl_entry; | 170 | struct ctl_table *sysctl_entry; |
234 | void *ns; | 171 | struct proc_ns ns; |
235 | const struct proc_ns_operations *ns_ops; | ||
236 | struct inode vfs_inode; | 172 | struct inode vfs_inode; |
237 | }; | 173 | }; |
238 | 174 | ||
diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h new file mode 100644 index 000000000000..34a1e105bef4 --- /dev/null +++ b/include/linux/proc_ns.h | |||
@@ -0,0 +1,74 @@ | |||
1 | /* | ||
2 | * procfs namespace bits | ||
3 | */ | ||
4 | #ifndef _LINUX_PROC_NS_H | ||
5 | #define _LINUX_PROC_NS_H | ||
6 | |||
7 | struct pid_namespace; | ||
8 | struct nsproxy; | ||
9 | |||
10 | struct proc_ns_operations { | ||
11 | const char *name; | ||
12 | int type; | ||
13 | void *(*get)(struct task_struct *task); | ||
14 | void (*put)(void *ns); | ||
15 | int (*install)(struct nsproxy *nsproxy, void *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 | }; | ||
23 | |||
24 | extern const struct proc_ns_operations netns_operations; | ||
25 | extern const struct proc_ns_operations utsns_operations; | ||
26 | extern const struct proc_ns_operations ipcns_operations; | ||
27 | extern const struct proc_ns_operations pidns_operations; | ||
28 | extern const struct proc_ns_operations userns_operations; | ||
29 | extern const struct proc_ns_operations mntns_operations; | ||
30 | |||
31 | /* | ||
32 | * We always define these enumerators | ||
33 | */ | ||
34 | enum { | ||
35 | PROC_ROOT_INO = 1, | ||
36 | PROC_IPC_INIT_INO = 0xEFFFFFFFU, | ||
37 | PROC_UTS_INIT_INO = 0xEFFFFFFEU, | ||
38 | PROC_USER_INIT_INO = 0xEFFFFFFDU, | ||
39 | PROC_PID_INIT_INO = 0xEFFFFFFCU, | ||
40 | }; | ||
41 | |||
42 | #ifdef CONFIG_PROC_FS | ||
43 | |||
44 | extern int pid_ns_prepare_proc(struct pid_namespace *ns); | ||
45 | 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); | ||
49 | extern void proc_free_inum(unsigned int inum); | ||
50 | extern bool proc_ns_inode(struct inode *inode); | ||
51 | |||
52 | #else /* CONFIG_PROC_FS */ | ||
53 | |||
54 | 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) {} | ||
56 | |||
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) | ||
65 | { | ||
66 | *inum = 1; | ||
67 | return 0; | ||
68 | } | ||
69 | static inline void proc_free_inum(unsigned int inum) {} | ||
70 | static inline bool proc_ns_inode(struct inode *inode) { return false; } | ||
71 | |||
72 | #endif /* CONFIG_PROC_FS */ | ||
73 | |||
74 | #endif /* _LINUX_PROC_NS_H */ | ||