[PATCH 3/3] fuse4fs: ask for loop devices when opening via fuservicemount

Darrick J. Wong
2026-04-29T14:58:22Z

When requesting a file, ask the fuservicemount program to transform an
open regular file into a loop device for us, so that we can use iomap
even when the filesystem is actually an image file.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
fuse4fs/fuse4fs.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fuse4fs/fuse4fs.c b/fuse4fs/fuse4fs.c
index e4338722e88e73..7c861fc28e9fa4 100644
--- a/fuse4fs/fuse4fs.c
+++ b/fuse4fs/fuse4fs.c
@@ -1491,13 +1491,18 @@ static int fuse4fs_service_get_config(struct fuse4fs *ff)
{
double deadline = init_deadline(FUSE4FS_OPEN_TIMEOUT);
const int open_flags = O_EXCL | (ff->directio ? O_DIRECT : 0);
+ unsigned int request_flags = 0;
int open_mode = O_RDWR;
int fd;
int ret;

+ if (fuse4fs_can_iomap(ff))
+ request_flags |= FUSE_SERVICE_REQUEST_FILE_TRYLOOP;
+
do {
ret = fuse_service_request_file(ff->service, ff->device,
- open_mode | open_flags, 0, 0);
+ open_mode | open_flags, 0,
+ request_flags);
if (ret)
return ret;