git: f61844833ee8 - main - vfs_vnops.c: Make O_NAMEDATTR Solaris compatible

From: Rick Macklem <rmacklem_at_FreeBSD.org>
Date: Sun, 04 May 2025 22:01:32 UTC
The branch main has been updated by rmacklem:

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

commit f61844833ee8e39f7568b27f562d7e26897bb73d
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2025-05-04 21:58:56 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2025-05-04 21:58:56 +0000

    vfs_vnops.c: Make O_NAMEDATTR Solaris compatible
    
    When the O_XATTR flag is used in a Solaris open(2),
    the named attribute directory is created, if it does
    not already exist. (Solaris does not require or allow
    O_CREAT for this case.)
    
    The consensus on the mailing list was that O_NAMEDATTR
    should behave the same way, as in "create the named
    attribute directory if it does not exist even if O_CREAT
    is not specified.
    
    This patch makes this change. Note that CREATENAMED is
    still useful for the NFSv4 server.
    
    Reviewed by:    kib
    Differential Revision:  https://reviews.freebsd.org/D50139
    Fixes:  2ec2ba7e232d ("vfs: Add VFS/syscall support for Solaris style extended attributes")
---
 sys/kern/vfs_vnops.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index f1d3ba2ac08b..eaa1d298bdc6 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -208,11 +208,8 @@ open2nameif(int fmode, u_int vn_open_flags)
 		res |= OPENREAD;
 	if ((fmode & FWRITE) != 0)
 		res |= OPENWRITE;
-	if ((fmode & O_NAMEDATTR) != 0) {
-		res |= OPENNAMED;
-		if ((fmode & O_CREAT) != 0)
-			res |= CREATENAMED;
-	}
+	if ((fmode & O_NAMEDATTR) != 0)
+		res |= OPENNAMED | CREATENAMED;
 	if ((vn_open_flags & VN_OPEN_NOAUDIT) == 0)
 		res |= AUDITVNODE1;
 	if ((vn_open_flags & VN_OPEN_NOCAPCHECK) != 0)