From: Darrick J. Wong Date: Tue, 7 Oct 2025 18:55:20 +0000 (-0700) Subject: libext2fs: the unixfd IO manager shouldn't close its fd X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c14eb7325c687768e3ba33507d022401e195776d;p=thirdparty%2Fe2fsprogs.git libext2fs: the unixfd IO manager shouldn't close its fd The unixfd IO manager didn't create the fd that was passed in, so it should not close the fd when the io channel closes. Cc: # v1.43.2 Fixes: 4ccf9e4fe165cf ("libext2fs: add unixfd_io_manager") Signed-off-by: "Darrick J. Wong" --- diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c index 723a5c24..1456b4d4 100644 --- a/lib/ext2fs/unix_io.c +++ b/lib/ext2fs/unix_io.c @@ -1061,7 +1061,7 @@ static errcode_t unix_open_channel(const char *name, int fd, cleanup: if (data) { - if (data->dev >= 0) + if (io->manager != unixfd_io_manager && data->dev >= 0) close(data->dev); if (data->cache) { free_cache(data); @@ -1147,7 +1147,7 @@ static errcode_t unix_close(io_channel channel) retval = flush_cached_blocks(channel, data, 0); #endif - if (close(data->dev) < 0) + if (channel->manager != unixfd_io_manager && close(data->dev) < 0) retval = errno; free_cache(data); free(data->cache);