Re: [PATCH v2] vfs: Shortcut AT_EMPTY_PATH early for statx, and add AT_NO_PATH for statx and fstatat

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx>
School of Aerospace Science and Technology, Xidian University





[Index of Archives]     [Linux Kernel]     [Kernel Newbies]     [x86 Platform Driver]     [Netdev]     [Linux Wireless]     [Netfilter]     [Bugtraq]     [Linux Filesystems]     [Yosemite Discussion]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux