From patchwork Tue May 5 05:22:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 6335381 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E30749F32B for ; Tue, 5 May 2015 05:43:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0A3C3202BE for ; Tue, 5 May 2015 05:43:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0EA672027D for ; Tue, 5 May 2015 05:43:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030526AbbEEFko (ORCPT ); Tue, 5 May 2015 01:40:44 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:39769 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755588AbbEEFXB (ORCPT ); Tue, 5 May 2015 01:23:01 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.76 #1 (Red Hat Linux)) id 1YpVJq-0001LJ-Va; Tue, 05 May 2015 05:22:59 +0000 From: Al Viro To: Linus Torvalds Cc: Neil Brown , Christoph Hellwig , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 37/79] namei: rename follow_link to trailing_symlink, move it down Date: Tue, 5 May 2015 06:22:11 +0100 Message-Id: <1430803373-4948-37-git-send-email-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <20150505052205.GS889@ZenIV.linux.org.uk> References: <20150505052205.GS889@ZenIV.linux.org.uk> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Al Viro Signed-off-by: Al Viro --- fs/namei.c | 62 ++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index a13e47d..7537ae0 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -668,8 +668,6 @@ static __always_inline void set_root(struct nameidata *nd) get_fs_root(current->fs, &nd->root); } -static int link_path_walk(const char *, struct nameidata *); - static __always_inline unsigned set_root_rcu(struct nameidata *nd) { struct fs_struct *fs = current->fs; @@ -880,33 +878,6 @@ out: return res; } -static int follow_link(struct path *link, struct nameidata *nd, void **p) -{ - const char *s; - int error = may_follow_link(link, nd); - if (unlikely(error)) - return error; - nd->flags |= LOOKUP_PARENT; - s = get_link(link, nd, p); - if (unlikely(IS_ERR(s))) - return PTR_ERR(s); - if (unlikely(!s)) - return 0; - if (*s == '/') { - if (!nd->root.mnt) - set_root(nd); - path_put(&nd->path); - nd->path = nd->root; - path_get(&nd->root); - nd->flags |= LOOKUP_JUMPED; - } - nd->inode = nd->path.dentry->d_inode; - error = link_path_walk(s, nd); - if (unlikely(error)) - put_link(nd, link, *p); - return error; -} - static int follow_up_rcu(struct path *path) { struct mount *mnt = real_mount(path->mnt); @@ -1962,6 +1933,33 @@ static void path_cleanup(struct nameidata *nd) fput(nd->base); } +static int trailing_symlink(struct path *link, struct nameidata *nd, void **p) +{ + const char *s; + int error = may_follow_link(link, nd); + if (unlikely(error)) + return error; + nd->flags |= LOOKUP_PARENT; + s = get_link(link, nd, p); + if (unlikely(IS_ERR(s))) + return PTR_ERR(s); + if (unlikely(!s)) + return 0; + if (*s == '/') { + if (!nd->root.mnt) + set_root(nd); + path_put(&nd->path); + nd->path = nd->root; + path_get(&nd->root); + nd->flags |= LOOKUP_JUMPED; + } + nd->inode = nd->path.dentry->d_inode; + error = link_path_walk(s, nd); + if (unlikely(error)) + put_link(nd, link, *p); + return error; +} + static inline int lookup_last(struct nameidata *nd) { if (nd->last_type == LAST_NORM && nd->last.name[nd->last.len]) @@ -1997,7 +1995,7 @@ static int path_lookupat(int dfd, const struct filename *name, while (err > 0) { void *cookie; struct path link = nd->link; - err = follow_link(&link, nd, &cookie); + err = trailing_symlink(&link, nd, &cookie); if (err) break; err = lookup_last(nd); @@ -2343,7 +2341,7 @@ path_mountpoint(int dfd, const struct filename *name, struct path *path, while (err > 0) { void *cookie; struct path link = *path; - err = follow_link(&link, nd, &cookie); + err = trailing_symlink(&link, nd, &cookie); if (err) break; err = mountpoint_last(nd, path); @@ -3229,7 +3227,7 @@ static struct file *path_openat(int dfd, struct filename *pathname, struct path link = nd->link; void *cookie; nd->flags &= ~(LOOKUP_OPEN|LOOKUP_CREATE|LOOKUP_EXCL); - error = follow_link(&link, nd, &cookie); + error = trailing_symlink(&link, nd, &cookie); if (unlikely(error)) break; error = do_last(nd, file, op, &opened, pathname);