Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp873729ybv; Sat, 22 Feb 2020 17:22:23 -0800 (PST) X-Google-Smtp-Source: APXvYqxgsb9DXtYWgTEO5pLio5B5tBF1jLzGDkZQrdakJ+odIrOLwgTXB1HETr1fM73Fs1CnpdOF X-Received: by 2002:a9d:470a:: with SMTP id a10mr35559718otf.370.1582420943358; Sat, 22 Feb 2020 17:22:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582420943; cv=none; d=google.com; s=arc-20160816; b=SZgX+AY/JT2tyCepprOj91qQL2uUKEVr6dhf/Bxrc8tncB96Ci8/xDa2bpYgnvERil FOMIgAj4jDg+l68hkt2tR9PQOt8OwhNh8CBWsT0lLuKVoNF6aaqBGEjNDM+5vbPHPafZ JNJcabKedrZ7f2DeNUudZMZ+AlsAgiHD5Yx6Rox4BWD5bj1RqHApEkS9KrIs8D5mf12q DIu/EKGUpiWfZuGHUQ2W47Yeg9IU2wfSfD/JMC7ODvWRK6xQUXAz/kxCt5FfadzZ0J8p XAHerGD13srMbX09OOim1JHSo10DEprNSeZBsfu+HbcWzMhyjYoyc/l2Lmhfzqw21p8/ gQFg== 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=UiPsN73Tx7jx1lhRSAjxE+TYndGh1hrKOySpX7hcmw4=; b=ZTke35b4kuW2YtLtlYRKP44NaxAeK5oDkcIcGMMdPpvz2xU/wIlazA5wJNPZt3aPSG rl6wCttkbwJ7jQM3uE7/6SKx2Fshliwy7FLSglH8aUZtiadbQRc+P5yaSpDpPwfyVIkz V80FZwA4vJ8MEbeb7D50eBpJbKCiE7KYkjOIvOaXj1HkMWyCKJo3ipE4oo79hYmxrNPw s3oJfc5Gz693MDmAGg1UB86q+OnubxcDws1t0tMfr1Ff2W202JdoV4tTzMOk+pFfsr1R yUNqvG8/F/jxomW+MVFB2rsNQJUc1cHsPpUc3O2+qiTN5BpsMOdtj6+8TV3YAUszGZKw PV0A== 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 z15si4037386oti.126.2020.02.22.17.22.11; Sat, 22 Feb 2020 17:22:23 -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 S1727207AbgBWBVT (ORCPT + 99 others); Sat, 22 Feb 2020 20:21:19 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:50178 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726884AbgBWBVT (ORCPT ); Sat, 22 Feb 2020 20:21:19 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1j5fx5-00HDgt-9k; Sun, 23 Feb 2020 01:21:04 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Linus Torvalds Subject: [RFC][PATCH v2 18/34] merging pick_link() with get_link(), part 1 Date: Sun, 23 Feb 2020 01:16:10 +0000 Message-Id: <20200223011626.4103706-18-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200223011626.4103706-1-viro@ZenIV.linux.org.uk> References: <20200223011154.GY23230@ZenIV.linux.org.uk> <20200223011626.4103706-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 3eed5784942a..3594f6a4998b 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -1115,6 +1115,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); @@ -2329,13 +2335,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.11.0