From 2a07a1f5abba308729bd082dce4d035365165d85 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Fri, 9 Dec 2016 16:45:03 +0100 Subject: 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 --- fs/proc/self.c | 14 +------------- fs/proc/thread_self.c | 15 +-------------- 2 files changed, 2 insertions(+), 27 deletions(-) (limited to 'fs/proc') 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 @@ /* * /proc/self: */ -static int proc_self_readlink(struct dentry *dentry, char __user *buffer, - int buflen) -{ - 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 -ENOENT; - sprintf(tmp, "%d", tgid); - return readlink_copy(buffer, buflen, tmp); -} - static const char *proc_self_get_link(struct dentry *dentry, struct inode *inode, struct delayed_call *done) @@ -38,7 +26,7 @@ static const char *proc_self_get_link(struct dentry *dentry, } static const struct inode_operations proc_self_inode_operations = { - .readlink = proc_self_readlink, + .readlink = generic_readlink, .get_link = proc_self_get_link, }; 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 @@ /* * /proc/thread_self: */ -static int proc_thread_self_readlink(struct dentry *dentry, char __user *buffer, - int buflen) -{ - struct pid_namespace *ns = dentry->d_sb->s_fs_info; - pid_t tgid = task_tgid_nr_ns(current, ns); - pid_t pid = task_pid_nr_ns(current, ns); - char tmp[PROC_NUMBUF + 6 + PROC_NUMBUF]; - if (!pid) - return -ENOENT; - sprintf(tmp, "%d/task/%d", tgid, pid); - return readlink_copy(buffer, buflen, tmp); -} - static const char *proc_thread_self_get_link(struct dentry *dentry, struct inode *inode, struct delayed_call *done) @@ -40,7 +27,7 @@ static const char *proc_thread_self_get_link(struct dentry *dentry, } static const struct inode_operations proc_thread_self_inode_operations = { - .readlink = proc_thread_self_readlink, + .readlink = generic_readlink, .get_link = proc_thread_self_get_link, }; -- cgit v1.2.3 From dfeef68862edd7d4bafe68ef7aeb5f658ef24bb5 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Fri, 9 Dec 2016 16:45:04 +0100 Subject: vfs: remove ".readlink = generic_readlink" assignments If .readlink == NULL implies generic_readlink(). Generated by: to_del="\.readlink.*=.*generic_readlink" for i in `git grep -l $to_del`; do sed -i "/$to_del"/d $i; done Signed-off-by: Miklos Szeredi --- fs/proc/inode.c | 1 - fs/proc/self.c | 1 - fs/proc/thread_self.c | 1 - 3 files changed, 3 deletions(-) (limited to 'fs/proc') diff --git a/fs/proc/inode.c b/fs/proc/inode.c index e69ebe648a34..827c0df5baa6 100644 --- a/fs/proc/inode.c +++ b/fs/proc/inode.c @@ -410,7 +410,6 @@ static const char *proc_get_link(struct dentry *dentry, } const struct inode_operations proc_link_inode_operations = { - .readlink = generic_readlink, .get_link = proc_get_link, }; diff --git a/fs/proc/self.c b/fs/proc/self.c index b7a29e55f802..39857f6db5cf 100644 --- a/fs/proc/self.c +++ b/fs/proc/self.c @@ -26,7 +26,6 @@ static const char *proc_self_get_link(struct dentry *dentry, } static const struct inode_operations proc_self_inode_operations = { - .readlink = generic_readlink, .get_link = proc_self_get_link, }; diff --git a/fs/proc/thread_self.c b/fs/proc/thread_self.c index adaba20b59b6..20614b62a9b7 100644 --- a/fs/proc/thread_self.c +++ b/fs/proc/thread_self.c @@ -27,7 +27,6 @@ static const char *proc_thread_self_get_link(struct dentry *dentry, } static const struct inode_operations proc_thread_self_inode_operations = { - .readlink = generic_readlink, .get_link = proc_thread_self_get_link, }; -- cgit v1.2.3