summaryrefslogtreecommitdiff
path: root/fs/proc
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2010-01-14 01:03:28 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2010-03-15 08:49:37 -0700
commit6b3a4b9c49dfd933ca05ef9a052da8355143b849 (patch)
treeefd54f2669b2145766693e7e3d13557161fd8d18 /fs/proc
parent5e0bf19b7e58825aac1c02df5e54fab697b910e5 (diff)
downloadlwn-6b3a4b9c49dfd933ca05ef9a052da8355143b849.tar.gz
lwn-6b3a4b9c49dfd933ca05ef9a052da8355143b849.zip
Switch proc/self to nd_set_link()
commit 7fee4868be91e71a3ee8e57289ebf5e10a12297e upstream. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'fs/proc')
-rw-r--r--fs/proc/base.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c
index af643b5aefe8..6d71c67a3024 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -2304,16 +2304,30 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
{
struct pid_namespace *ns = dentry->d_sb->s_fs_info;
pid_t tgid = task_tgid_nr_ns(current, ns);
- char tmp[PROC_NUMBUF];
- if (!tgid)
- return ERR_PTR(-ENOENT);
- sprintf(tmp, "%d", task_tgid_nr_ns(current, ns));
- return ERR_PTR(vfs_follow_link(nd,tmp));
+ char *name = ERR_PTR(-ENOENT);
+ if (tgid) {
+ name = __getname();
+ if (!name)
+ name = ERR_PTR(-ENOMEM);
+ else
+ sprintf(name, "%d", tgid);
+ }
+ nd_set_link(nd, name);
+ return NULL;
+}
+
+static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
+ void *cookie)
+{
+ char *s = nd_get_link(nd);
+ if (!IS_ERR(s))
+ __putname(s);
}
static const struct inode_operations proc_self_inode_operations = {
.readlink = proc_self_readlink,
.follow_link = proc_self_follow_link,
+ .put_link = proc_self_put_link,
};
/*