[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <176169814922.1428772.8400025430143585718.stgit@frogsfrogsfrogs>
Date: Tue, 28 Oct 2025 18:08:10 -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 4/5] libfuse: enable setting iomap block device block size
From: Darrick J. Wong <djwong@...nel.org>
Create a means for an unprivileged fuse server to set the block size of
a block device that it previously opened and associated with the fuse
connection.
Signed-off-by: "Darrick J. Wong" <djwong@...nel.org>
---
include/fuse_kernel.h | 7 +++++++
include/fuse_lowlevel.h | 12 ++++++++++++
lib/fuse_lowlevel.c | 11 +++++++++++
lib/fuse_versionscript | 1 +
4 files changed, 31 insertions(+)
diff --git a/include/fuse_kernel.h b/include/fuse_kernel.h
index 0638d774d36cbc..adf23f4214223b 100644
--- a/include/fuse_kernel.h
+++ b/include/fuse_kernel.h
@@ -1172,6 +1172,11 @@ struct fuse_iomap_support {
uint64_t padding;
};
+struct fuse_iomap_backing_info {
+ uint32_t backing_id;
+ uint32_t blocksize;
+};
+
/* Device ioctls: */
#define FUSE_DEV_IOC_MAGIC 229
#define FUSE_DEV_IOC_CLONE _IOR(FUSE_DEV_IOC_MAGIC, 0, uint32_t)
@@ -1181,6 +1186,8 @@ struct fuse_iomap_support {
#define FUSE_DEV_IOC_ADD_IOMAP _IO(FUSE_DEV_IOC_MAGIC, 99)
#define FUSE_DEV_IOC_IOMAP_SUPPORT _IOR(FUSE_DEV_IOC_MAGIC, 99, \
struct fuse_iomap_support)
+#define FUSE_DEV_IOC_IOMAP_SET_BLOCKSIZE _IOW(FUSE_DEV_IOC_MAGIC, 99, \
+ struct fuse_iomap_backing_info)
struct fuse_lseek_in {
uint64_t fh;
diff --git a/include/fuse_lowlevel.h b/include/fuse_lowlevel.h
index a93f3e27f6ef6d..63477ec4eeff33 100644
--- a/include/fuse_lowlevel.h
+++ b/include/fuse_lowlevel.h
@@ -2729,6 +2729,18 @@ uint64_t fuse_lowlevel_discover_iomap(int fd);
*/
int fuse_lowlevel_add_iomap(int fd);
+/**
+ * Set the block size of an open block device that has been opened for use with
+ * iomap.
+ *
+ * @param fd open file descriptor to a fuse device
+ * @param dev_index device index returned by fuse_lowlevel_iomap_device_add
+ * @param blocksize block size in bytes
+ * @return 0 on success, -1 on failure with errno set
+ */
+int fuse_lowlevel_iomap_set_blocksize(int fd, int dev_index,
+ unsigned int blocksize);
+
#ifdef __cplusplus
}
#endif
diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c
index 51c609761494af..60d2b28bbef683 100644
--- a/lib/fuse_lowlevel.c
+++ b/lib/fuse_lowlevel.c
@@ -4995,3 +4995,14 @@ int fuse_lowlevel_add_iomap(int fd)
{
return ioctl(fd, FUSE_DEV_IOC_ADD_IOMAP);
}
+
+int fuse_lowlevel_iomap_set_blocksize(int fd, int dev_index,
+ unsigned int blocksize)
+{
+ struct fuse_iomap_backing_info fbi = {
+ .backing_id = dev_index,
+ .blocksize = blocksize,
+ };
+
+ return ioctl(fd, FUSE_DEV_IOC_IOMAP_SET_BLOCKSIZE, &fbi);
+}
diff --git a/lib/fuse_versionscript b/lib/fuse_versionscript
index 2adab40e0eab1f..d34b68903faa33 100644
--- a/lib/fuse_versionscript
+++ b/lib/fuse_versionscript
@@ -256,6 +256,7 @@ FUSE_3.99 {
fuse_service_request_file;
fuse_service_send_goodbye;
fuse_service_take_fusedev;
+ fuse_lowlevel_iomap_set_blocksize;
} FUSE_3.18;
# Local Variables:
Powered by blists - more mailing lists