From 73ddf5dd6ea009d20177f6a2d7b80bdcacba0d10 Mon Sep 17 00:00:00 2001 From: Alessio Balsini Date: Thu, 13 May 2021 11:38:53 +0100 Subject: Introduce API V2 for FUSE_PASSTHROUGH_OPEN From the feedback received on LKML, it would be better to have multiple ioctls, than a single ioctl the behavior of which depends on the data that is passed (e.g., with an enum). Introduce the new FUSE_PASSTHROUGH_OPEN ioctl which only gets the fd of the lower file system. Bug: 175195837 Test: CtsScopedStorageDeviceOnlyTest with android-mainline kernel \ implementing the new FUSE_PASSTHROUGH_OPEN ioctl Signed-off-by: Alessio Balsini Change-Id: Iecb677722ca9630ce89b8a8fb5f486216ecd89cc --- include/fuse_kernel.h | 1 + lib/fuse_lowlevel.c | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/fuse_kernel.h b/include/fuse_kernel.h index 55d8e2c..bd8794e 100644 --- a/include/fuse_kernel.h +++ b/include/fuse_kernel.h @@ -836,6 +836,7 @@ struct fuse_notify_retrieve_in { #define FUSE_DEV_IOC_CLONE _IOR(229, 0, uint32_t) #define FUSE_DEV_IOC_PASSTHROUGH_OPEN_V0 _IOW(229, 1, struct fuse_passthrough_out_v0) #define FUSE_DEV_IOC_PASSTHROUGH_OPEN_V1 _IOW(229, 127, struct fuse_passthrough_out_v0) +#define FUSE_DEV_IOC_PASSTHROUGH_OPEN_V2 _IOW(229, 126, uint32_t) struct fuse_lseek_in { uint64_t fh; diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c index baa6d2b..a4a4df0 100644 --- a/lib/fuse_lowlevel.c +++ b/lib/fuse_lowlevel.c @@ -463,6 +463,7 @@ enum { FUSE_PASSTHROUGH_API_UNAVAILABLE, FUSE_PASSTHROUGH_API_V0, FUSE_PASSTHROUGH_API_V1, + FUSE_PASSTHROUGH_API_V2, FUSE_PASSTHROUGH_API_STABLE, }; @@ -490,7 +491,14 @@ int fuse_passthrough_enable(fuse_req_t req, unsigned int fd) { switch (passthrough_version) { case FUSE_PASSTHROUGH_API_STABLE: /* There is not a stable API yet */ - passthrough_version = FUSE_PASSTHROUGH_API_V1; + passthrough_version = FUSE_PASSTHROUGH_API_V2; + case FUSE_PASSTHROUGH_API_V2: { + ret = ioctl(req->se->fd, FUSE_DEV_IOC_PASSTHROUGH_OPEN_V2, &fd); + if (ret == -1 && errno == ENOTTY) + passthrough_version = FUSE_PASSTHROUGH_API_V1; + else + break; + } case FUSE_PASSTHROUGH_API_V1: { struct fuse_passthrough_out_v0 out = {}; out.fd = fd; -- cgit v1.2.3