git: 1e44a4ea0d4a - stable/13 - linux: support AT_EMPTY_PATH flag in fchownat(2)

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

URL: https://cgit.FreeBSD.org/src/commit/?id=1e44a4ea0d4ab6ae9b022293233bba8719f0515e

commit 1e44a4ea0d4ab6ae9b022293233bba8719f0515e
Author:     Edward Tomasz Napierala <trasz@FreeBSD.org>
AuthorDate: 2021-04-16 15:26:43 +0000
Commit:     Edward Tomasz Napierala <trasz@FreeBSD.org>
CommitDate: 2022-02-13 21:06:38 +0000

    linux: support AT_EMPTY_PATH flag in fchownat(2)
    
    This fixes rsyslog package installation scripts in Bionic.
    
    Reviewed By:    kib
    Sponsored By:   EPSRC
    Differential Revision:  https://reviews.freebsd.org/D29108
    
    (cherry picked from commit e47823b8312b7cb61c5c8cb8e1eb981994e3a0b4)
---
 sys/compat/linux/linux_file.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c
index 438b100d4e21..6b02c2efb88e 100644
--- a/sys/compat/linux/linux_file.c
+++ b/sys/compat/linux/linux_file.c
@@ -1740,12 +1740,17 @@ linux_fchownat(struct thread *td, struct linux_fchownat_args *args)
 	char *path;
 	int error, dfd, flag;
 
-	if (args->flag & ~LINUX_AT_SYMLINK_NOFOLLOW)
+	if (args->flag & ~(LINUX_AT_SYMLINK_NOFOLLOW | LINUX_AT_EMPTY_PATH)) {
+		linux_msg(td, "fchownat unsupported flag 0x%x", args->flag);
 		return (EINVAL);
+	}
 
-	dfd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD :  args->dfd;
 	flag = (args->flag & LINUX_AT_SYMLINK_NOFOLLOW) == 0 ? 0 :
 	    AT_SYMLINK_NOFOLLOW;
+	flag |= (args->flag & LINUX_AT_EMPTY_PATH) == 0 ? 0 :
+	    AT_EMPTY_PATH;
+
+	dfd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD :  args->dfd;
 	if (!LUSECONVPATH(td)) {
 		return (kern_fchownat(td, dfd, args->filename, UIO_USERSPACE,
 		    args->uid, args->gid, flag));