aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2013-04-11 20:50:06 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2013-05-01 17:29:39 -0400
commit0bb80f240520c4148b623161e7856858c021696d (patch)
treeeeb27af589bc12d5864bd2594e5eea59aabe37db /include
parentc3bef7bcaaa7d9f6704fcd81a171c9f0c91a2259 (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.h68
-rw-r--r--include/linux/proc_ns.h74
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
10struct net; 11struct net;
11struct completion; 12struct 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
30enum {
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,
81extern void remove_proc_entry(const char *name, struct proc_dir_entry *parent); 70extern void remove_proc_entry(const char *name, struct proc_dir_entry *parent);
82extern int remove_proc_subtree(const char *name, struct proc_dir_entry *parent); 71extern int remove_proc_subtree(const char *name, struct proc_dir_entry *parent);
83 72
84struct pid_namespace;
85
86extern int pid_ns_prepare_proc(struct pid_namespace *ns);
87extern 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
133extern void proc_set_size(struct proc_dir_entry *, loff_t); 118extern void proc_set_size(struct proc_dir_entry *, loff_t);
134extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t); 119extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
135
136extern struct file *proc_ns_fget(int fd);
137extern bool proc_ns_inode(struct inode *inode);
138
139extern int proc_alloc_inum(unsigned int *pino);
140extern void proc_free_inum(unsigned int inum);
141#else 120#else
142 121
143static inline void proc_flush_task(struct task_struct *task) 122static inline void proc_flush_task(struct task_struct *task)
@@ -168,50 +147,8 @@ struct tty_driver;
168static inline void proc_tty_register_driver(struct tty_driver *driver) {}; 147static inline void proc_tty_register_driver(struct tty_driver *driver) {};
169static inline void proc_tty_unregister_driver(struct tty_driver *driver) {}; 148static inline void proc_tty_unregister_driver(struct tty_driver *driver) {};
170 149
171static inline int pid_ns_prepare_proc(struct pid_namespace *ns)
172{
173 return 0;
174}
175
176static inline void pid_ns_release_proc(struct pid_namespace *ns)
177{
178}
179
180static inline struct file *proc_ns_fget(int fd)
181{
182 return ERR_PTR(-EINVAL);
183}
184
185static inline bool proc_ns_inode(struct inode *inode)
186{
187 return false;
188}
189
190static inline int proc_alloc_inum(unsigned int *inum)
191{
192 *inum = 1;
193 return 0;
194}
195static inline void proc_free_inum(unsigned int inum)
196{
197}
198#endif /* CONFIG_PROC_FS */ 150#endif /* CONFIG_PROC_FS */
199 151
200struct nsproxy;
201struct 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};
209extern const struct proc_ns_operations netns_operations;
210extern const struct proc_ns_operations utsns_operations;
211extern const struct proc_ns_operations ipcns_operations;
212extern const struct proc_ns_operations pidns_operations;
213extern const struct proc_ns_operations userns_operations;
214extern const struct proc_ns_operations mntns_operations;
215 152
216union proc_op { 153union 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
7struct pid_namespace;
8struct nsproxy;
9
10struct 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
19struct proc_ns {
20 void *ns;
21 const struct proc_ns_operations *ns_ops;
22};
23
24extern const struct proc_ns_operations netns_operations;
25extern const struct proc_ns_operations utsns_operations;
26extern const struct proc_ns_operations ipcns_operations;
27extern const struct proc_ns_operations pidns_operations;
28extern const struct proc_ns_operations userns_operations;
29extern const struct proc_ns_operations mntns_operations;
30
31/*
32 * We always define these enumerators
33 */
34enum {
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
44extern int pid_ns_prepare_proc(struct pid_namespace *ns);
45extern void pid_ns_release_proc(struct pid_namespace *ns);
46extern struct file *proc_ns_fget(int fd);
47extern struct proc_ns *get_proc_ns(struct inode *);
48extern int proc_alloc_inum(unsigned int *pino);
49extern void proc_free_inum(unsigned int inum);
50extern bool proc_ns_inode(struct inode *inode);
51
52#else /* CONFIG_PROC_FS */
53
54static inline int pid_ns_prepare_proc(struct pid_namespace *ns) { return 0; }
55static inline void pid_ns_release_proc(struct pid_namespace *ns) {}
56
57static inline struct file *proc_ns_fget(int fd)
58{
59 return ERR_PTR(-EINVAL);
60}
61
62static inline struct proc_ns *get_proc_ns(struct inode *inode) { return NULL; }
63
64static inline int proc_alloc_inum(unsigned int *inum)
65{
66 *inum = 1;
67 return 0;
68}
69static inline void proc_free_inum(unsigned int inum) {}
70static inline bool proc_ns_inode(struct inode *inode) { return false; }
71
72#endif /* CONFIG_PROC_FS */
73
74#endif /* _LINUX_PROC_NS_H */