aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ext2fs/io_manager.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2008-08-27 21:46:26 -0400
committerTheodore Ts'o <tytso@mit.edu>2008-08-27 21:46:26 -0400
commit4690e621acd4579dae60b6f55f58284ee805e86d (patch)
tree89eba34ab7b6edc61c91ea9e26058d2fb47e02ab /lib/ext2fs/io_manager.c
parent75b5672f6f82f4946b4b3f20cfe69946b6cb8210 (diff)
downloadandroid_external_e2fsprogs-4690e621acd4579dae60b6f55f58284ee805e86d.tar.gz
android_external_e2fsprogs-4690e621acd4579dae60b6f55f58284ee805e86d.tar.bz2
android_external_e2fsprogs-4690e621acd4579dae60b6f55f58284ee805e86d.zip
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>
Diffstat (limited to 'lib/ext2fs/io_manager.c')
-rw-r--r--lib/ext2fs/io_manager.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/ext2fs/io_manager.c b/lib/ext2fs/io_manager.c
index e50d7e41..8d732530 100644
--- a/lib/ext2fs/io_manager.c
+++ b/lib/ext2fs/io_manager.c
@@ -67,3 +67,35 @@ errcode_t io_channel_write_byte(io_channel channel, unsigned long offset,
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);
+}