git: 572680712c31 - main - nfs_clvnops.c: Fix the case where va_flags are being cleared

From: Rick Macklem <rmacklem_at_FreeBSD.org>
Date: Thu, 18 Jun 2026 00:37:08 UTC
The branch main has been updated by rmacklem:

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

commit 572680712c317b81d66475203ac1b9d6bbeca5d5
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2026-06-18 00:30:29 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2026-06-18 00:34:57 +0000

    nfs_clvnops.c: Fix the case where va_flags are being cleared
    
    Commits c5d72d2 and 3b6d4c6 broke the case where the
    archive/hidden/system attributes are being set false
    (UF_ARCHIVE, UF_HIDDEN or UF_SYSTEM bits being cleared.)
    and the NFS server does not support those attributes.
    These patches only checked for support if the
    archive/hidden/system attributes were non-zero.
    
    This patch fixes the problem.
    
    PR:     296088
    Tested by:      Joshua Kinard <freebsd@kumba.dev>
    MFC after:      1 week
    Fixes:  c5d72d29fe0e ("nfsv4: Add support for the NFSv4 hidden and system attributes")
---
 sys/fs/nfsclient/nfs_clvnops.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c
index 26aa6491ac4a..5081e442882e 100644
--- a/sys/fs/nfsclient/nfs_clvnops.c
+++ b/sys/fs/nfsclient/nfs_clvnops.c
@@ -1033,12 +1033,9 @@ nfs_setattr(struct vop_setattr_args *ap)
 	nmp = VFSTONFS(vp->v_mount);
 	if (vap->va_flags != VNOVAL && (!NFSHASNFSV4(nmp) ||
 	    (vap->va_flags & ~(UF_ARCHIVE | UF_HIDDEN | UF_SYSTEM)) != 0 ||
-	    ((vap->va_flags & UF_ARCHIVE) != 0 &&
-	     !NFSISSET_ATTRBIT(&np->n_vattr.na_suppattr, NFSATTRBIT_ARCHIVE)) ||
-	    ((vap->va_flags & UF_HIDDEN) != 0 &&
-	     !NFSISSET_ATTRBIT(&np->n_vattr.na_suppattr, NFSATTRBIT_HIDDEN)) ||
-	    ((vap->va_flags & UF_SYSTEM) != 0 &&
-	     !NFSISSET_ATTRBIT(&np->n_vattr.na_suppattr, NFSATTRBIT_SYSTEM))))
+	     !NFSISSET_ATTRBIT(&np->n_vattr.na_suppattr, NFSATTRBIT_ARCHIVE) ||
+	     !NFSISSET_ATTRBIT(&np->n_vattr.na_suppattr, NFSATTRBIT_HIDDEN) ||
+	     !NFSISSET_ATTRBIT(&np->n_vattr.na_suppattr, NFSATTRBIT_SYSTEM)))
 		return (EOPNOTSUPP);
 
 	/*