aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc
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 /fs/proc
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 'fs/proc')
-rw-r--r--fs/proc/inode.c8
-rw-r--r--fs/proc/namespaces.c17
2 files changed, 15 insertions, 10 deletions
diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index bd2f76427fec..073aea60cf8f 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -51,8 +51,8 @@ static void proc_evict_inode(struct inode *inode)
51 sysctl_head_put(head); 51 sysctl_head_put(head);
52 } 52 }
53 /* Release any associated namespace */ 53 /* Release any associated namespace */
54 ns_ops = PROC_I(inode)->ns_ops; 54 ns_ops = PROC_I(inode)->ns.ns_ops;
55 ns = PROC_I(inode)->ns; 55 ns = PROC_I(inode)->ns.ns;
56 if (ns_ops && ns) 56 if (ns_ops && ns)
57 ns_ops->put(ns); 57 ns_ops->put(ns);
58} 58}
@@ -73,8 +73,8 @@ static struct inode *proc_alloc_inode(struct super_block *sb)
73 ei->pde = NULL; 73 ei->pde = NULL;
74 ei->sysctl = NULL; 74 ei->sysctl = NULL;
75 ei->sysctl_entry = NULL; 75 ei->sysctl_entry = NULL;
76 ei->ns = NULL; 76 ei->ns.ns = NULL;
77 ei->ns_ops = NULL; 77 ei->ns.ns_ops = NULL;
78 inode = &ei->vfs_inode; 78 inode = &ei->vfs_inode;
79 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; 79 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
80 return inode; 80 return inode;
diff --git a/fs/proc/namespaces.c b/fs/proc/namespaces.c
index 66b51c0383da..54bdc6701e9f 100644
--- a/fs/proc/namespaces.c
+++ b/fs/proc/namespaces.c
@@ -51,7 +51,7 @@ static int ns_delete_dentry(const struct dentry *dentry)
51static char *ns_dname(struct dentry *dentry, char *buffer, int buflen) 51static char *ns_dname(struct dentry *dentry, char *buffer, int buflen)
52{ 52{
53 struct inode *inode = dentry->d_inode; 53 struct inode *inode = dentry->d_inode;
54 const struct proc_ns_operations *ns_ops = PROC_I(inode)->ns_ops; 54 const struct proc_ns_operations *ns_ops = PROC_I(inode)->ns.ns_ops;
55 55
56 return dynamic_dname(dentry, buffer, buflen, "%s:[%lu]", 56 return dynamic_dname(dentry, buffer, buflen, "%s:[%lu]",
57 ns_ops->name, inode->i_ino); 57 ns_ops->name, inode->i_ino);
@@ -95,8 +95,8 @@ static struct dentry *proc_ns_get_dentry(struct super_block *sb,
95 inode->i_op = &ns_inode_operations; 95 inode->i_op = &ns_inode_operations;
96 inode->i_mode = S_IFREG | S_IRUGO; 96 inode->i_mode = S_IFREG | S_IRUGO;
97 inode->i_fop = &ns_file_operations; 97 inode->i_fop = &ns_file_operations;
98 ei->ns_ops = ns_ops; 98 ei->ns.ns_ops = ns_ops;
99 ei->ns = ns; 99 ei->ns.ns = ns;
100 unlock_new_inode(inode); 100 unlock_new_inode(inode);
101 } else { 101 } else {
102 ns_ops->put(ns); 102 ns_ops->put(ns);
@@ -128,7 +128,7 @@ static void *proc_ns_follow_link(struct dentry *dentry, struct nameidata *nd)
128 if (!ptrace_may_access(task, PTRACE_MODE_READ)) 128 if (!ptrace_may_access(task, PTRACE_MODE_READ))
129 goto out_put_task; 129 goto out_put_task;
130 130
131 ns_path.dentry = proc_ns_get_dentry(sb, task, ei->ns_ops); 131 ns_path.dentry = proc_ns_get_dentry(sb, task, ei->ns.ns_ops);
132 if (IS_ERR(ns_path.dentry)) { 132 if (IS_ERR(ns_path.dentry)) {
133 error = ERR_CAST(ns_path.dentry); 133 error = ERR_CAST(ns_path.dentry);
134 goto out_put_task; 134 goto out_put_task;
@@ -148,7 +148,7 @@ static int proc_ns_readlink(struct dentry *dentry, char __user *buffer, int bufl
148{ 148{
149 struct inode *inode = dentry->d_inode; 149 struct inode *inode = dentry->d_inode;
150 struct proc_inode *ei = PROC_I(inode); 150 struct proc_inode *ei = PROC_I(inode);
151 const struct proc_ns_operations *ns_ops = ei->ns_ops; 151 const struct proc_ns_operations *ns_ops = ei->ns.ns_ops;
152 struct task_struct *task; 152 struct task_struct *task;
153 void *ns; 153 void *ns;
154 char name[50]; 154 char name[50];
@@ -202,7 +202,7 @@ static struct dentry *proc_ns_instantiate(struct inode *dir,
202 ei = PROC_I(inode); 202 ei = PROC_I(inode);
203 inode->i_mode = S_IFLNK|S_IRWXUGO; 203 inode->i_mode = S_IFLNK|S_IRWXUGO;
204 inode->i_op = &proc_ns_link_inode_operations; 204 inode->i_op = &proc_ns_link_inode_operations;
205 ei->ns_ops = ns_ops; 205 ei->ns.ns_ops = ns_ops;
206 206
207 d_set_d_op(dentry, &pid_dentry_operations); 207 d_set_d_op(dentry, &pid_dentry_operations);
208 d_add(dentry, inode); 208 d_add(dentry, inode);
@@ -337,6 +337,11 @@ out_invalid:
337 return ERR_PTR(-EINVAL); 337 return ERR_PTR(-EINVAL);
338} 338}
339 339
340struct proc_ns *get_proc_ns(struct inode *inode)
341{
342 return &PROC_I(inode)->ns;
343}
344
340bool proc_ns_inode(struct inode *inode) 345bool proc_ns_inode(struct inode *inode)
341{ 346{
342 return inode->i_fop == &ns_file_operations; 347 return inode->i_fop == &ns_file_operations;