aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@redhat.com>2016-12-09 10:45:03 -0500
committerMiklos Szeredi <mszeredi@redhat.com>2016-12-09 10:45:03 -0500
commit2a07a1f5abba308729bd082dce4d035365165d85 (patch)
tree6608a88e5bb8552fb061430eea7f6955d81544cd
parent6c988f575915ab5162332d61f91dca99dcc17335 (diff)
proc/self: use generic_readlink
The /proc/self and /proc/self-thread symlinks have separate but identical functionality for reading and following. This cleanup utilizes generic_readlink to remove the duplication. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
-rw-r--r--fs/proc/self.c14
-rw-r--r--fs/proc/thread_self.c15
2 files changed, 2 insertions, 27 deletions
diff --git a/fs/proc/self.c b/fs/proc/self.c
index 40245954c450..b7a29e55f802 100644
--- a/fs/proc/self.c
+++ b/fs/proc/self.c
@@ -6,18 +6,6 @@
6/* 6/*
7 * /proc/self: 7 * /proc/self:
8 */ 8 */
9static int proc_self_readlink(struct dentry *dentry, char __user *buffer,
10 int buflen)
11{
12 struct pid_namespace *ns = dentry->d_sb->s_fs_info;
13 pid_t tgid = task_tgid_nr_ns(current, ns);
14 char tmp[PROC_NUMBUF];
15 if (!tgid)
16 return -ENOENT;
17 sprintf(tmp, "%d", tgid);
18 return readlink_copy(buffer, buflen, tmp);
19}
20
21static const char *proc_self_get_link(struct dentry *dentry, 9static const char *proc_self_get_link(struct dentry *dentry,
22 struct inode *inode, 10 struct inode *inode,
23 struct delayed_call *done) 11 struct delayed_call *done)
@@ -38,7 +26,7 @@ static const char *proc_self_get_link(struct dentry *dentry,
38} 26}
39 27
40static const struct inode_operations proc_self_inode_operations = { 28static const struct inode_operations proc_self_inode_operations = {
41 .readlink = proc_self_readlink, 29 .readlink = generic_readlink,
42 .get_link = proc_self_get_link, 30 .get_link = proc_self_get_link,
43}; 31};
44 32
diff --git a/fs/proc/thread_self.c b/fs/proc/thread_self.c
index 595b90a9766c..adaba20b59b6 100644
--- a/fs/proc/thread_self.c
+++ b/fs/proc/thread_self.c
@@ -6,19 +6,6 @@
6/* 6/*
7 * /proc/thread_self: 7 * /proc/thread_self:
8 */ 8 */
9static int proc_thread_self_readlink(struct dentry *dentry, char __user *buffer,
10 int buflen)
11{
12 struct pid_namespace *ns = dentry->d_sb->s_fs_info;
13 pid_t tgid = task_tgid_nr_ns(current, ns);
14 pid_t pid = task_pid_nr_ns(current, ns);
15 char tmp[PROC_NUMBUF + 6 + PROC_NUMBUF];
16 if (!pid)
17 return -ENOENT;
18 sprintf(tmp, "%d/task/%d", tgid, pid);
19 return readlink_copy(buffer, buflen, tmp);
20}
21
22static const char *proc_thread_self_get_link(struct dentry *dentry, 9static const char *proc_thread_self_get_link(struct dentry *dentry,
23 struct inode *inode, 10 struct inode *inode,
24 struct delayed_call *done) 11 struct delayed_call *done)
@@ -40,7 +27,7 @@ static const char *proc_thread_self_get_link(struct dentry *dentry,
40} 27}
41 28
42static const struct inode_operations proc_thread_self_inode_operations = { 29static const struct inode_operations proc_thread_self_inode_operations = {
43 .readlink = proc_thread_self_readlink, 30 .readlink = generic_readlink,
44 .get_link = proc_thread_self_get_link, 31 .get_link = proc_thread_self_get_link,
45}; 32};
46 33