From patchwork Mon Sep 12 19:29:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 9327899 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EC0DC6077F for ; Mon, 12 Sep 2016 19:35:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE685287A8 for ; Mon, 12 Sep 2016 19:35:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D138A28D4C; Mon, 12 Sep 2016 19:35:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F4FF287A8 for ; Mon, 12 Sep 2016 19:35:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758118AbcILT33 (ORCPT ); Mon, 12 Sep 2016 15:29:29 -0400 Received: from mail-wm0-f49.google.com ([74.125.82.49]:38490 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758098AbcILT31 (ORCPT ); Mon, 12 Sep 2016 15:29:27 -0400 Received: by mail-wm0-f49.google.com with SMTP id 1so163048097wmz.1 for ; Mon, 12 Sep 2016 12:29:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=B6Bu7qOmpzC6oMSnXUdbs5tlroU7TIbu6DEkWEy8rBs=; b=BZNTZfhBIwvJTnzNR4BJYzhaSAPg/OgflHo+llot2eCErKSiAhNMZMBJPEg3wxZXEo 8Jc2qmp8tD67YVQO6FB2YoG/0LdDVKfgSYjBNMLlq+6w7AaasFulx82+D66uu1e912Qa fL/oDzjNZbY1YRCvdf2Dcv3Dd/bye2daz0kqG3arB1k116QDNl9Wbm8dLLBWwkLTniNF 6bZK88bkcqpuPPNEdzUDm6UqkQncEnJP31fE3HXAwC6+MRJ/ZPtNSmtuSN5xx+tYJYOu V/yux9AmdfnEPLVWtCBM6kH2LZE9SSYOjwlytLtD7zq2xHkqpRLC00lPCIhIIv4Qmmc9 IATw== X-Gm-Message-State: AE9vXwPM6eKiq1j+C3Kk70snV1ssfAIFu0V/bvq+y4t+F6swL3RJR10ejq3KRtCzSo/vkdWW X-Received: by 10.194.122.137 with SMTP id ls9mr16585123wjb.29.1473708565818; Mon, 12 Sep 2016 12:29:25 -0700 (PDT) Received: from veci.piliscsaba.szeredi.hu (pool-dsl-2c-0018.externet.hu. [217.173.44.24]) by smtp.gmail.com with ESMTPSA id f8sm19250418wjh.45.2016.09.12.12.29.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Sep 2016 12:29:24 -0700 (PDT) From: Miklos Szeredi To: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Al Viro Subject: [PATCH 03/17] proc/self: use generic_readlink Date: Mon, 12 Sep 2016 21:29:05 +0200 Message-Id: <1473708559-12714-4-git-send-email-mszeredi@redhat.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1473708559-12714-1-git-send-email-mszeredi@redhat.com> References: <1473708559-12714-1-git-send-email-mszeredi@redhat.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This will also allow us to move the generic readlink logic into the VFS and get rid of the readlink method. 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(-) diff --git a/fs/proc/self.c b/fs/proc/self.c index b6a8d3529fea..80bc52fd7846 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 e58a31e8fb2a..55053d5280ff 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, };