[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <176169814355.1428390.16043068248654100347.stgit@frogsfrogsfrogs>
Date: Tue, 28 Oct 2025 18:05:49 -0700
From: "Darrick J. Wong" <djwong@...nel.org>
To: djwong@...nel.org, bschubert@....com
Cc: linux-ext4@...r.kernel.org, linux-fsdevel@...r.kernel.org,
bernd@...ernd.com, miklos@...redi.hu, joannelkoong@...il.com, neal@...pa.dev
Subject: [PATCH 2/4] libfuse: set sync, immutable,
and append when loading files
From: Darrick J. Wong <djwong@...nel.org>
Add these three fuse_attr::flags bits so that servers can mark a file as
immutable or append-only and have the kernel advertise and enforce that.
Signed-off-by: "Darrick J. Wong" <djwong@...nel.org>
---
include/fuse_common.h | 6 ++++++
include/fuse_kernel.h | 8 ++++++++
lib/fuse_lowlevel.c | 6 ++++++
3 files changed, 20 insertions(+)
diff --git a/include/fuse_common.h b/include/fuse_common.h
index 83ab3f54f54a2e..5df95ba35ce341 100644
--- a/include/fuse_common.h
+++ b/include/fuse_common.h
@@ -1241,6 +1241,12 @@ static inline bool fuse_iomap_need_write_allocate(unsigned int opflags,
#define FUSE_IFLAG_IOMAP (1U << 1)
/* enable untorn writes */
#define FUSE_IFLAG_ATOMIC (1U << 2)
+/* file writes are synchronous */
+#define FUSE_IFLAG_SYNC (1U << 3)
+/* file is immutable */
+#define FUSE_IFLAG_IMMUTABLE (1U << 4)
+/* file is append only */
+#define FUSE_IFLAG_APPEND (1U << 5)
/* Which fields are set in fuse_iomap_config_out? */
#define FUSE_IOMAP_CONFIG_SID (1 << 0ULL)
diff --git a/include/fuse_kernel.h b/include/fuse_kernel.h
index 37e5eb8c65f206..6fd0397b758eae 100644
--- a/include/fuse_kernel.h
+++ b/include/fuse_kernel.h
@@ -246,6 +246,8 @@
* - add FUSE_IOMAP_CONFIG so the fuse server can configure more fs geometry
* - add FUSE_NOTIFY_IOMAP_DEV_INVAL to invalidate iomap bdev ranges
* - add FUSE_ATTR_ATOMIC for single-fsblock atomic write support
+ * - add FUSE_ATTR_{SYNC,IMMUTABLE,APPEND} for VFS enforcement of file
+ * attributes
*/
#ifndef _LINUX_FUSE_H
@@ -588,11 +590,17 @@ struct fuse_file_lock {
* FUSE_ATTR_DAX: Enable DAX for this file in per inode DAX mode
* FUSE_ATTR_IOMAP: Use iomap for this inode
* FUSE_ATTR_ATOMIC: Enable untorn writes
+ * FUSE_ATTR_SYNC: File writes are always synchronous
+ * FUSE_ATTR_IMMUTABLE: File is immutable
+ * FUSE_ATTR_APPEND: File is append-only
*/
#define FUSE_ATTR_SUBMOUNT (1 << 0)
#define FUSE_ATTR_DAX (1 << 1)
#define FUSE_ATTR_IOMAP (1 << 2)
#define FUSE_ATTR_ATOMIC (1 << 3)
+#define FUSE_ATTR_SYNC (1 << 4)
+#define FUSE_ATTR_IMMUTABLE (1 << 5)
+#define FUSE_ATTR_APPEND (1 << 6)
/**
* Open flags
diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c
index 728a6b635471c7..3ab4a532b4edbb 100644
--- a/lib/fuse_lowlevel.c
+++ b/lib/fuse_lowlevel.c
@@ -129,6 +129,12 @@ static void convert_stat(const struct stat *stbuf, struct fuse_attr *attr,
attr->flags |= FUSE_ATTR_IOMAP;
if (iflags & FUSE_IFLAG_ATOMIC)
attr->flags |= FUSE_ATTR_ATOMIC;
+ if (iflags & FUSE_IFLAG_SYNC)
+ attr->flags |= FUSE_ATTR_SYNC;
+ if (iflags & FUSE_IFLAG_IMMUTABLE)
+ attr->flags |= FUSE_ATTR_IMMUTABLE;
+ if (iflags & FUSE_IFLAG_APPEND)
+ attr->flags |= FUSE_ATTR_APPEND;
}
static void convert_attr(const struct fuse_setattr_in *attr, struct stat *stbuf)
Powered by blists - more mailing lists