Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1125915ybl; Sat, 18 Jan 2020 19:24:57 -0800 (PST) X-Google-Smtp-Source: APXvYqxYrdKKNpbkn0K/JZA3zdjbG+qNdXXkq7jrfUYPXe+EUBubn7oYqptP2L0GfI7prfF0yQNr X-Received: by 2002:aca:c507:: with SMTP id v7mr8942177oif.157.1579404297121; Sat, 18 Jan 2020 19:24:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579404297; cv=none; d=google.com; s=arc-20160816; b=nVGp23dm5HaNnIqg60b0lMI4X5JKB3FlZcgosrMuOHoAG9TJJ3HaFaJjSfYX7PhBI7 by8JImiMvP49AJBWG8gji1Nn2G9ZNn6dNC3DVJ8lQmWs7THLSMS9q7BLJA3jPf6lyD9W TkB4fGlOrjR2aNLwkcKk6cejFdZ1SuNQcmGKHJlxFgII6RhHASrHmQjiMwPAn8OF2YXz Yuf7wsTYw4udJ8Dgf8+AktzJ9U4VRtAPlrhlC8BMwPOoAGZUmPjvGThDQ3W12ljp8+rd 5jwnmEYQNnyBsNRiIgQhiurmwHnLGFqaONbwAC7pKUaozmW6V+iu0GHJO+aBWHvV2Z/Z pEYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=d608heh0KZrxtzz5LMqWJoIKVnAoEtKhiVl0cp9zxFQ=; b=IEW9L8eQ9XcKS7BcpTZXEi2ztF88/n3z9IOoKAR+CIpuGmqgigID6LW7t8wwDG9x81 BRhRFB3nqKOIvPJMbUzVpqZGj7AhMVc/untXk332wgO0acOLOiHwOQU+h1SdtYGyiBcs Y1BxftsgzCbIaJKwRkV0jgYniM5kAkU1XRKhNlqr3+NYfVX42G+mCebYekjWztyhdXBu BzM/gW9H9r4T0lEtlXzdFvwYOWER73d+VV2JXF+9cN2GQ/jjekDgHIGYPy15rClDjctu YeEcVtCidUN0XPHEEl5A6Qjzho02yo/FUdL2aq/LBB+/j8tsbyhETvLvOGwIKo+FCH46 9cYA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n11si16959727otq.112.2020.01.18.19.24.45; Sat, 18 Jan 2020 19:24:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726982AbgASDXs (ORCPT + 99 others); Sat, 18 Jan 2020 22:23:48 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:56908 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725497AbgASDXr (ORCPT ); Sat, 18 Jan 2020 22:23:47 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1it1BA-00BFe0-Gr; Sun, 19 Jan 2020 03:23:20 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: Linus Torvalds , linux-kernel@vger.kernel.org, Aleksa Sarai , David Howells , Eric Biederman , Christian Brauner , Al Viro Subject: [PATCH 1/9] merging pick_link() with get_link(), part 1 Date: Sun, 19 Jan 2020 03:17:30 +0000 Message-Id: <20200119031738.2681033-18-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200119031738.2681033-1-viro@ZenIV.linux.org.uk> References: <20200119031423.GV8904@ZenIV.linux.org.uk> <20200119031738.2681033-1-viro@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Al Viro Move restoring LOOKUP_PARENT and zeroing nd->stack.name[0] past the call of get_link() (nothing _currently_ uses them in there). That allows to moved the call of may_follow_link() into get_link() as well, since now the presence of LOOKUP_PARENT distinguishes the callers from each other (link_path_walk() has it, trailing_symlink() doesn't). Preparations for folding trailing_symlink() into callers (lookup_last() and do_last()) and changing the calling conventions of those. Next stage after that will have get_link() call migrate into walk_component(), then - into step_into(). It's tricky enough to warrant doing that in stages, unfortunately... Signed-off-by: Al Viro --- fs/namei.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index f9fa8579cf6a..45cedbe267ab 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -1114,6 +1114,12 @@ const char *get_link(struct nameidata *nd) int error; const char *res; + if (!(nd->flags & LOOKUP_PARENT)) { + error = may_follow_link(nd); + if (unlikely(error)) + return ERR_PTR(error); + } + if (unlikely(nd->flags & LOOKUP_NO_SYMLINKS)) return ERR_PTR(-ELOOP); @@ -2328,13 +2334,9 @@ static const char *path_init(struct nameidata *nd, unsigned flags) static const char *trailing_symlink(struct nameidata *nd) { - const char *s; - int error = may_follow_link(nd); - if (unlikely(error)) - return ERR_PTR(error); + const char *s = get_link(nd); nd->flags |= LOOKUP_PARENT; nd->stack[0].name = NULL; - s = get_link(nd); return s ? s : ""; } -- 2.20.1