Improve future compatibility for the 64-bit I/O channel functions
Provide a C language wrapper function for io_channel_read_blk64() and
io_channel_write_blk64() instead of using a C preprocessor macro, with
an fallback to the old 32-bit functions if an application-provided I/O
channel manager doesn't supply 64-bit method functions and the block
numbers can fit in 32-bit integer.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
diff --git a/lib/ext2fs/io_manager.c b/lib/ext2fs/io_manager.c
index e50d7e4..8d73253 100644
--- a/lib/ext2fs/io_manager.c
+++ b/lib/ext2fs/io_manager.c
@@ -67,3 +67,35 @@
return EXT2_ET_UNIMPLEMENTED;
}
+
+errcode_t io_channel_read_blk64(io_channel channel, unsigned long long block,
+ int count, void *data)
+{
+ EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
+
+ if (channel->manager->read_blk64)
+ return (channel->manager->read_blk64)(channel, block,
+ count, data);
+
+ if ((block >> 32) != 0)
+ return EXT2_ET_IO_CHANNEL_NO_SUPPORT_64;
+
+ return (channel->manager->read_blk)(channel, (unsigned long) block,
+ count, data);
+}
+
+errcode_t io_channel_write_blk64(io_channel channel, unsigned long long block,
+ int count, const void *data)
+{
+ EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
+
+ if (channel->manager->write_blk64)
+ return (channel->manager->write_blk64)(channel, block,
+ count, data);
+
+ if ((block >> 32) != 0)
+ return EXT2_ET_IO_CHANNEL_NO_SUPPORT_64;
+
+ return (channel->manager->write_blk)(channel, (unsigned long) block,
+ count, data);
+}