From f61844833ee8e39f7568b27f562d7e26897bb73d Mon Sep 17 00:00:00 2001 From: Rick Macklem Date: Sun, 4 May 2025 14:58:56 -0700 Subject: [PATCH] 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 f1d3ba2ac08..eaa1d298bdc 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)