mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Xi Ruoyao <xry111@xry111.site>
To: Mateusz Guzik <mjguzik@gmail.com>,
	Linus Torvalds <torvalds@linux-foundation.org>
Cc: Christian Brauner <brauner@kernel.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>, Jan Kara <jack@suse.cz>,
	Alejandro Colomar <alx@kernel.org>, Arnd Bergmann <arnd@arndb.de>,
	Huacai Chen <chenhuacai@loongson.cn>,
	Xuerui Wang <kernel@xen0n.name>,
	Jiaxun Yang <jiaxun.yang@flygoat.com>,
	Icenowy Zheng <uwu@icenowy.me>,
	 linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org,
	 loongarch@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] vfs: Shortcut AT_EMPTY_PATH early for statx, and add AT_NO_PATH for statx and fstatat
Date: Mon, 24 Jun 2024 20:19:33 +0800	[thread overview]
Message-ID: <b635271e73b35487a06cf17176243e6ce4cfcd58.camel@xry111.site> (raw)
In-Reply-To: <e2lv3qamggymdjqzujvyhsd2q34jy5tryniac7d446tlaebqwy@5x4zn7z4d3xz>

On Mon, 2024-06-24 at 11:04 +0200, Mateusz Guzik wrote:
> Below is a diff which compiles but is untested. It adds AT_EMPTY_PATH +
> NULL as suggsted by Linus, but it can be adjusted for AT_NO_PATH (which
> would be my preffered option, or better yet not do that and add fstatx).
> 
> It does not do the hack to 0-check if a pointer was passed along with
> AT_EMPTY_PATH but that again is an easy addition.
> 
> Feel free to take without attribution:

I'd still like to make it Co-developed-by: or just From: you.  Could you
give a S-o-b?

And with this change AT_FDCWD with AT_EMPTY_PATH and NULL path does not
work.  For consistency it'd be better to make it work too:

diff --git a/fs/stat.c b/fs/stat.c
index b0a4db7b90df..d04f7ba46645 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -752,10 +752,14 @@ SYSCALL_DEFINE5(statx,
 	int ret;
 	struct filename *name;
 
-	if (filename == NULL && (flags & AT_EMPTY_PATH))
-		return do_statx_fd(dfd, flags, mask, buffer);
+	if (filename == NULL && (flags & AT_EMPTY_PATH)) {
+		if (dfd >= 0)
+			return do_statx_fd(dfd, flags, mask, buffer);
+		else
+			name = getname_kernel("");
+	} else
+		name = getname_flags(filename, getname_statx_lookup_flags(flags));
 
-	name = getname_flags(filename, getname_statx_lookup_flags(flags));
 	ret = do_statx(dfd, name, flags, mask, buffer);
 	putname(name);
 
And should we do it for fstatat() as well?

Let's wait for comment from Linus anyway.

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University

  reply	other threads:[~2024-06-24 12:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-24  8:50 Xi Ruoyao
2024-06-24  8:54 ` Xi Ruoyao
2024-06-24  9:04 ` Mateusz Guzik
2024-06-24 12:19   ` Xi Ruoyao [this message]
2024-06-24 12:28     ` Mateusz Guzik
2024-06-25  8:50   ` Christian Brauner
2024-06-25 10:51     ` Xi Ruoyao
2024-06-25 10:52       ` Mateusz Guzik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b635271e73b35487a06cf17176243e6ce4cfcd58.camel@xry111.site \
    --to=xry111@xry111.site \
    --cc=alx@kernel.org \
    --cc=arnd@arndb.de \
    --cc=brauner@kernel.org \
    --cc=chenhuacai@loongson.cn \
    --cc=jack@suse.cz \
    --cc=jiaxun.yang@flygoat.com \
    --cc=kernel@xen0n.name \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --cc=mjguzik@gmail.com \
    --cc=torvalds@linux-foundation.org \
    --cc=uwu@icenowy.me \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®