vfs_default.c: Add _PC_HAS_NAMEDATTR pathconf name

Commit f61844833e changes the semantics of O_NAMEDATTR so
that a named attribute directory will be created if it
does not already exist. As such, an open(2) without
O_CREAT cannot be used to test to see if one exists.

This patch adds a new pathconf name _PC_HAS_NAMEDATTR,
which returns 1 if one or more named attributes are associated
with the file. This is similar to Solaris's _PC_XATTR_EXISTS.
A return of 0 means that there are none, so there.
is no need to open(2) the named attribute directory.
This allows applications to avoid creating unnecessary named
attribute directories when the application only wishes to read
named attributes and not create them.

It is also useful for the NFSv4 server, so that it can reply with
a correct named_attr attribute.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D50140
Fixes:	2ec2ba7e23 ("vfs: Add VFS/syscall support for Solaris style extended attributes")
This commit is contained in:
Rick Macklem 2025-05-04 15:06:01 -07:00
parent 9c05d6320c
commit 0f12c3cd0d
2 changed files with 2 additions and 0 deletions

View file

@ -452,6 +452,7 @@ vop_stdpathconf(struct vop_pathconf_args *ap)
case _PC_INF_PRESENT:
case _PC_MAC_PRESENT:
case _PC_NAMEDATTR_ENABLED:
case _PC_HAS_NAMEDATTR:
*ap->a_retval = 0;
return (0);
default:

View file

@ -155,6 +155,7 @@
#define _PC_ACL_NFS4 64
#define _PC_DEALLOC_PRESENT 65
#define _PC_NAMEDATTR_ENABLED 66
#define _PC_HAS_NAMEDATTR 67
#endif
/* From OpenSolaris, used by SEEK_DATA/SEEK_HOLE. */