git: 290e563166b4 - main - chflags: Add a new UF_NOCACHE flag
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 26 Aug 2026 21:58:12 UTC
The branch main has been updated by rmacklem:
URL: https://cgit.FreeBSD.org/src/commit/?id=290e563166b453413e1bf976b0819c301d559cad
commit 290e563166b453413e1bf976b0819c301d559cad
Author: Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2026-08-26 21:55:20 +0000
Commit: Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2026-08-26 21:55:20 +0000
chflags: Add a new UF_NOCACHE flag
This internet draft (which is close to being an RFC)
specifies a new NFSv4.2 attribute which tells the NFSv4.2
client to not cache file data. (Similar to O_DIRECT, but
triggered by this attribute set on the file on the NFSv4.2
server and not by the application's open(2).)
https://datatracker.ietf.org/doc/draft-ietf-nfsv4-uncacheable-files/
This patch adds a new chflags(1) flag called UF_NOCACHE to
implement this.
Patches for NFS and ZFS will be done separately.
This is a redo of the patch, with a requested name change
and a #ifdef in strtofflags.c so that it doesn't break some
Linux cross build. The name change was requested by fuz@.
Reviewed by: kib (earlier version)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D58181
---
lib/libc/gen/strtofflags.c | 6 ++++++
sys/fs/tmpfs/tmpfs_subr.c | 2 +-
sys/sys/stat.h | 1 +
sys/ufs/ufs/ufs_vnops.c | 2 +-
4 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/lib/libc/gen/strtofflags.c b/lib/libc/gen/strtofflags.c
index 73b4db54ccdd..4c8d5c4030b6 100644
--- a/lib/libc/gen/strtofflags.c
+++ b/lib/libc/gen/strtofflags.c
@@ -80,7 +80,13 @@ static struct {
{ "nosparse", 0, UF_SPARSE },
{ "nousparse", 0, UF_SPARSE },
{ "nosystem", 0, UF_SYSTEM },
+ /* Needed for some Linux cross-build that uses a stale stat.h. */
+#ifdef UF_NOCACHE
+ { "nousystem", 0, UF_SYSTEM },
+ { "noucache", 1, UF_NOCACHE }
+#else
{ "nousystem", 0, UF_SYSTEM }
+#endif
};
#define nmappings (sizeof(mapping) / sizeof(mapping[0]))
diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c
index dd281d18d87d..113a985c0b30 100644
--- a/sys/fs/tmpfs/tmpfs_subr.c
+++ b/sys/fs/tmpfs/tmpfs_subr.c
@@ -2042,7 +2042,7 @@ tmpfs_chflags(struct vnode *vp, u_long flags, struct ucred *cred,
if ((flags & ~(SF_APPEND | SF_ARCHIVED | SF_IMMUTABLE | SF_NOUNLINK |
UF_APPEND | UF_ARCHIVE | UF_HIDDEN | UF_IMMUTABLE | UF_NODUMP |
UF_NOUNLINK | UF_OFFLINE | UF_OPAQUE | UF_READONLY | UF_REPARSE |
- UF_SPARSE | UF_SYSTEM)) != 0)
+ UF_SPARSE | UF_SYSTEM | UF_NOCACHE)) != 0)
return (EOPNOTSUPP);
/* Disallow this operation if the file system is mounted read-only. */
diff --git a/sys/sys/stat.h b/sys/sys/stat.h
index 0c58838094ed..ccea0760c8e4 100644
--- a/sys/sys/stat.h
+++ b/sys/sys/stat.h
@@ -327,6 +327,7 @@ struct nstat {
#define UF_REPARSE 0x00000400 /* Windows reparse point file bit */
#define UF_ARCHIVE 0x00000800 /* file needs to be archived */
#define UF_READONLY 0x00001000 /* Windows readonly file bit */
+#define UF_NOCACHE 0x00002000 /* don't cache file data (NFSv4) */
/* This is the same as the MacOS X definition of UF_HIDDEN. */
#define UF_HIDDEN 0x00008000 /* file is hidden */
diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c
index 1d04e1b2785f..3c79c8814085 100644
--- a/sys/ufs/ufs/ufs_vnops.c
+++ b/sys/ufs/ufs/ufs_vnops.c
@@ -667,7 +667,7 @@ ufs_setattr(
SF_NOUNLINK | SF_SNAPSHOT | UF_APPEND | UF_ARCHIVE |
UF_HIDDEN | UF_IMMUTABLE | UF_NODUMP | UF_NOUNLINK |
UF_OFFLINE | UF_OPAQUE | UF_READONLY | UF_REPARSE |
- UF_SPARSE | UF_SYSTEM)) != 0)
+ UF_SPARSE | UF_SYSTEM | UF_NOCACHE)) != 0)
return (EOPNOTSUPP);
if (vp->v_mount->mnt_flag & MNT_RDONLY)
return (EROFS);