From: "Darrick J. Wong" <djwong@kernel.org>
To: tytso@mit.edu
Cc: linux-ext4@vger.kernel.org
Subject: [PATCH 01/10] libext2fs: make it possible to extract the fd from an IO manager
Date: Thu, 25 Jun 2026 12:37:00 -0700 [thread overview]
Message-ID: <178241606830.1810414.9069545784261735781.stgit@frogsfrogsfrogs> (raw)
In-Reply-To: <178241606773.1810414.1910863348345107939.stgit@frogsfrogsfrogs>
From: Darrick J. Wong <djwong@kernel.org>
Make it so that we can extract the fd from an open IO manager. This
will be used in subsequent patches to register the open block device
with the fuse iomap kernel driver.
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
lib/ext2fs/ext2_io.h | 4 +++-
debian/libext2fs2t64.symbols | 1 +
lib/ext2fs/io_manager.c | 8 ++++++++
lib/ext2fs/unix_io.c | 20 ++++++++++++++++++++
4 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/lib/ext2fs/ext2_io.h b/lib/ext2fs/ext2_io.h
index 61865d54d82490..c880ea2524f248 100644
--- a/lib/ext2fs/ext2_io.h
+++ b/lib/ext2fs/ext2_io.h
@@ -103,7 +103,8 @@ struct struct_io_manager {
errcode_t (*zeroout)(io_channel channel, unsigned long long block,
unsigned long long count);
errcode_t (*flock)(io_channel channel, unsigned int flock_flags);
- long reserved[13];
+ errcode_t (*get_fd)(io_channel channel, int *fd);
+ long reserved[12];
};
#define IO_FLAG_RW 0x0001
@@ -155,6 +156,7 @@ extern errcode_t io_channel_cache_readahead(io_channel io,
unsigned long long count);
extern errcode_t io_channel_flock(io_channel io, unsigned int flock_flags);
extern errcode_t io_channel_funlock(io_channel io);
+extern errcode_t io_channel_get_fd(io_channel io, int *fd);
#ifdef _WIN32
/* windows_io.c */
diff --git a/debian/libext2fs2t64.symbols b/debian/libext2fs2t64.symbols
index affe4c27d4e791..555fbbb0c98878 100644
--- a/debian/libext2fs2t64.symbols
+++ b/debian/libext2fs2t64.symbols
@@ -701,6 +701,7 @@ libext2fs.so.2 libext2fs2t64 #MINVER#
io_channel_discard@Base 1.42
io_channel_flock@Base 1.47.99
io_channel_funlock@Base 1.47.99
+ io_channel_get_fd@Base 1.47.99
io_channel_read_blk64@Base 1.41.1
io_channel_set_options@Base 1.37
io_channel_write_blk64@Base 1.41.1
diff --git a/lib/ext2fs/io_manager.c b/lib/ext2fs/io_manager.c
index 791ec7d14adbba..dff3d73552827f 100644
--- a/lib/ext2fs/io_manager.c
+++ b/lib/ext2fs/io_manager.c
@@ -166,3 +166,11 @@ errcode_t io_channel_funlock(io_channel io)
return io->manager->flock(io, 0);
}
+
+errcode_t io_channel_get_fd(io_channel io, int *fd)
+{
+ if (!io->manager->get_fd)
+ return EXT2_ET_OP_NOT_SUPPORTED;
+
+ return io->manager->get_fd(io, fd);
+}
diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c
index f4307db0fb2b05..79bc9219f9515b 100644
--- a/lib/ext2fs/unix_io.c
+++ b/lib/ext2fs/unix_io.c
@@ -1786,6 +1786,24 @@ static errcode_t unix_zeroout(io_channel channel, unsigned long long block,
unimplemented:
return EXT2_ET_UNIMPLEMENTED;
}
+
+static errcode_t unix_get_fd(io_channel channel, int *fd)
+{
+ struct unix_private_data *data;
+
+ EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
+ data = (struct unix_private_data *) channel->private_data;
+ EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_UNIX_IO_CHANNEL);
+
+ if (data->offset) {
+ *fd = -1;
+ return EINVAL;
+ }
+
+ *fd = data->dev;
+ return 0;
+}
+
#if __GNUC_PREREQ (4, 6)
#pragma GCC diagnostic pop
#endif
@@ -1808,6 +1826,7 @@ static struct struct_io_manager struct_unix_manager = {
.cache_readahead = unix_cache_readahead,
.zeroout = unix_zeroout,
.flock = unix_flock,
+ .get_fd = unix_get_fd,
};
io_manager unix_io_manager = &struct_unix_manager;
@@ -1830,6 +1849,7 @@ static struct struct_io_manager struct_unixfd_manager = {
.cache_readahead = unix_cache_readahead,
.zeroout = unix_zeroout,
.flock = unix_flock,
+ .get_fd = unix_get_fd,
};
io_manager unixfd_io_manager = &struct_unixfd_manager;
next prev parent reply other threads:[~2026-06-25 19:37 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-25 19:33 [PATCHBOMB v6] e2fsprogs: containerize ext4 for safer operation Darrick J. Wong
2026-06-25 19:35 ` [PATCHSET 1/4] libext2fs: fix some missed fsync calls Darrick J. Wong
2026-06-25 19:36 ` [PATCH 1/3] libext2fs: always fsync the device when flushing the cache Darrick J. Wong
2026-06-25 19:36 ` [PATCH 2/3] libext2fs: always fsync the device when closing the unix IO manager Darrick J. Wong
2026-06-25 19:36 ` [PATCH 3/3] libext2fs: only fsync the unix fd if we wrote to the device Darrick J. Wong
2026-06-25 19:35 ` [PATCHSET v6 2/4] fuse4fs: run servers as a contained service Darrick J. Wong
2026-06-25 19:37 ` Darrick J. Wong [this message]
2026-06-25 19:37 ` [PATCH 02/10] libext2fs: fix checking for valid fds in mmp.c Darrick J. Wong
2026-06-25 19:37 ` [PATCH 03/10] unix_io: allow passing /dev/fd/XXX paths to the unixfd IO manager Darrick J. Wong
2026-06-25 19:37 ` [PATCH 04/10] libext2fs: fix MMP code to work with " Darrick J. Wong
2026-06-25 19:38 ` [PATCH 05/10] libext2fs: bump libfuse API version to 3.19 Darrick J. Wong
2026-06-25 19:38 ` [PATCH 06/10] fuse4fs: hoist some code out of fuse4fs_main Darrick J. Wong
2026-06-25 19:38 ` [PATCH 07/10] fuse4fs: enable safe service mode Darrick J. Wong
2026-06-25 19:38 ` [PATCH 08/10] fuse4fs: set proc title when in fuse " Darrick J. Wong
2026-06-25 19:39 ` [PATCH 09/10] fuse4fs: make MMP work correctly in safe " Darrick J. Wong
2026-06-25 19:39 ` [PATCH 10/10] debian: update packaging for fuse4fs service Darrick J. Wong
2026-06-25 19:35 ` [PATCHSET v6 3/4] fuse2fs: improve block and inode caching Darrick J. Wong
2026-06-25 19:39 ` [PATCH 1/6] libsupport: add caching IO manager Darrick J. Wong
2026-06-25 19:39 ` [PATCH 2/6] iocache: add the actual buffer cache Darrick J. Wong
2026-06-25 19:40 ` [PATCH 3/6] iocache: bump buffer mru priority every 50 accesses Darrick J. Wong
2026-06-25 19:40 ` [PATCH 4/6] fuse2fs: enable caching IO manager Darrick J. Wong
2026-06-25 19:40 ` [PATCH 5/6] fuse2fs: increase inode cache size Darrick J. Wong
2026-06-25 19:40 ` [PATCH 6/6] libext2fs: improve caching for inodes Darrick J. Wong
2026-06-25 19:35 ` [PATCHSET v6 4/4] fuse4fs: reclaim buffer cache under memory pressure Darrick J. Wong
2026-06-25 19:41 ` [PATCH 1/4] libsupport: add pressure stall monitor Darrick J. Wong
2026-06-25 19:41 ` [PATCH 2/4] fuse2fs: only reclaim buffer cache when there is memory pressure Darrick J. Wong
2026-06-25 19:41 ` [PATCH 3/4] fuse4fs: enable memory pressure monitoring with service containers Darrick J. Wong
2026-06-25 19:41 ` [PATCH 4/4] fuse2fs: flush dirty metadata periodically Darrick J. Wong
-- strict thread matches above, loose matches on Subject: below --
2026-04-22 23:19 [PATCHSET v5 2/2] fuse4fs: run servers as a contained service Darrick J. Wong
2026-04-22 23:23 ` [PATCH 01/10] libext2fs: make it possible to extract the fd from an IO manager Darrick J. Wong
2025-09-16 0:22 [PATCHSET RFC v5 3/9] libext2fs: refactoring for fuse2fs iomap support Darrick J. Wong
2025-09-16 0:56 ` [PATCH 01/10] libext2fs: make it possible to extract the fd from an IO manager Darrick J. Wong
2025-08-21 0:49 [PATCHSET RFC v4 2/6] libext2fs: refactoring for fuse2fs iomap support Darrick J. Wong
2025-08-21 1:13 ` [PATCH 01/10] libext2fs: make it possible to extract the fd from an IO manager Darrick J. Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=178241606830.1810414.9069545784261735781.stgit@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox