git: 8e4ef1c3a3d9 - stable/13 - linux: make fstatat(2) handle AT_EMPTY_PATH

From: Edward Tomasz Napierala <trasz_at_FreeBSD.org>
Date: Thu, 17 Feb 2022 10:55:27 UTC
The branch stable/13 has been updated by trasz:

URL: https://cgit.FreeBSD.org/src/commit/?id=8e4ef1c3a3d93811b65be448fb4650786a66a430

commit 8e4ef1c3a3d93811b65be448fb4650786a66a430
Author:     Edward Tomasz Napierala <trasz@FreeBSD.org>
AuthorDate: 2021-04-16 07:52:59 +0000
Commit:     Edward Tomasz Napierala <trasz@FreeBSD.org>
CommitDate: 2022-02-13 21:06:37 +0000

    linux: make fstatat(2) handle AT_EMPTY_PATH
    
    Without it, Qt5 apps from Focal fail to start, being unable to load
    their plugins.  It's also necessary for glibc 2.33, as found in recent
    Arch snapshots.
    
    PR:             254112
    Reviewed By:    kib
    Sponsored by:   The FreeBSD Foundation, EPSRC
    Differential Revision:  https://reviews.freebsd.org/D28192
    
    (cherry picked from commit 4b45c2bb83a1d7aded0c424d65595cc576760dc7)
---
 sys/compat/linux/linux_stats.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/sys/compat/linux/linux_stats.c b/sys/compat/linux/linux_stats.c
index 01f9cada670b..c88f6f53bdd7 100644
--- a/sys/compat/linux/linux_stats.c
+++ b/sys/compat/linux/linux_stats.c
@@ -632,10 +632,14 @@ linux_fstatat64(struct thread *td, struct linux_fstatat64_args *args)
 	int error, dfd, flag;
 	struct stat buf;
 
-	if (args->flag & ~LINUX_AT_SYMLINK_NOFOLLOW)
+	if (args->flag & ~(LINUX_AT_SYMLINK_NOFOLLOW | LINUX_AT_EMPTY_PATH)) {
+		linux_msg(td, "fstatat64 unsupported flag 0x%x", args->flag);
 		return (EINVAL);
+	}
 	flag = (args->flag & LINUX_AT_SYMLINK_NOFOLLOW) ?
 	    AT_SYMLINK_NOFOLLOW : 0;
+	flag |= (args->flag & LINUX_AT_EMPTY_PATH) ?
+	    AT_EMPTY_PATH : 0;
 
 	dfd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd;
 	if (!LUSECONVPATH(td)) {
@@ -661,10 +665,15 @@ linux_newfstatat(struct thread *td, struct linux_newfstatat_args *args)
 	int error, dfd, flag;
 	struct stat buf;
 
-	if (args->flag & ~LINUX_AT_SYMLINK_NOFOLLOW)
+	if (args->flag & ~(LINUX_AT_SYMLINK_NOFOLLOW | LINUX_AT_EMPTY_PATH)) {
+		linux_msg(td, "fstatat unsupported flag 0x%x", args->flag);
 		return (EINVAL);
+	}
+
 	flag = (args->flag & LINUX_AT_SYMLINK_NOFOLLOW) ?
 	    AT_SYMLINK_NOFOLLOW : 0;
+	flag |= (args->flag & LINUX_AT_EMPTY_PATH) ?
+	    AT_EMPTY_PATH : 0;
 
 	dfd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd;
 	if (!LUSECONVPATH(td)) {