]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
proc/self: use generic_readlink
authorMiklos Szeredi <mszeredi@redhat.com>
Fri, 9 Dec 2016 15:45:03 +0000 (16:45 +0100)
committerMiklos Szeredi <mszeredi@redhat.com>
Fri, 9 Dec 2016 15:45:03 +0000 (16:45 +0100)
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>
fs/proc/self.c
fs/proc/thread_self.c

index 40245954c4501e838b15a00b68b7105ab9ab759a..b7a29e55f8027dc0db915adc9775966ddcc6137e 100644 (file)
@@ -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,
 };
 
index 595b90a9766c98c93014418486397f0e508873f1..adaba20b59b6e456ef5a0c81a5fcee549d6600fc 100644 (file)
@@ -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,
 };