]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
Improve future compatibility for the 64-bit I/O channel functions
authorTheodore Ts'o <tytso@mit.edu>
Thu, 28 Aug 2008 01:46:26 +0000 (21:46 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 28 Aug 2008 01:46:26 +0000 (21:46 -0400)
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>
debian/e2fslibs.symbols
lib/ext2fs/ext2_err.et.in
lib/ext2fs/ext2_io.h
lib/ext2fs/io_manager.c

index 836731a8b631244849e882d9fc8c75d446e7fe2e..00887bac6ee9d28e0681947b306c810a5f05ff87 100644 (file)
@@ -370,6 +370,8 @@ libext2fs.so.2 e2fslibs #MINVER#
  inode_io_manager@Base 1.37-2sarge1
  io_channel_set_options@Base 1.37-2sarge1
  io_channel_write_byte@Base 1.37-2sarge1
+ io_channel_read_blk64@Base 1.41.1-1
+ io_channel_write_blk64@Base 1.41.1-1
  set_undo_io_backing_manager@Base 1.41.0-1
  set_undo_io_backup_file@Base 1.41.0-1
  tdb_null@Base 1.40-1
index a072fb826e676c19c8e2ccd240159951cc4111fb..9ffffbb4995a9ae1c22a576558318ba1579913e3 100644 (file)
@@ -413,4 +413,7 @@ ec  EXT2_ET_EXTENT_NOT_SUPPORTED,
 ec     EXT2_ET_EXTENT_INVALID_LENGTH,
        "Extent length is invalid"
 
+ec     EXT2_ET_IO_CHANNEL_NO_SUPPORT_64,
+       "I/O Channel does not support 64-bit block numbers"
+
        end
index d9bbcca63f4cc5c0b19e070841097a9ae2f3c93f..dce21386266a922e25f8324befb0d754e1ca98f4 100644 (file)
@@ -51,7 +51,7 @@ struct struct_io_channel {
                                       errcode_t error);
        int             refcount;
        int             flags;
-       int             reserved[14];
+       long            reserved[14];
        void            *private_data;
        void            *app_data;
 };
@@ -83,7 +83,7 @@ struct struct_io_manager {
                                        int count, void *data);
        errcode_t (*write_blk64)(io_channel channel, unsigned long long block,
                                        int count, const void *data);
-       int             reserved[16];
+       long    reserved[16];
 };
 
 #define IO_FLAG_RW             0x0001
@@ -95,9 +95,7 @@ struct struct_io_manager {
 #define io_channel_close(c)            ((c)->manager->close((c)))
 #define io_channel_set_blksize(c,s)    ((c)->manager->set_blksize((c),s))
 #define io_channel_read_blk(c,b,n,d)   ((c)->manager->read_blk((c),b,n,d))
-#define io_channel_read_blk64(c,b,n,d) ((c)->manager->read_blk64((c),b,n,d))
 #define io_channel_write_blk(c,b,n,d)  ((c)->manager->write_blk((c),b,n,d))
-#define io_channel_write_blk64(c,b,n,d) ((c)->manager->write_blk64((c),b,n,d))
 #define io_channel_flush(c)            ((c)->manager->flush((c)))
 #define io_channel_bumpcount(c)                ((c)->refcount++)
        
@@ -107,6 +105,12 @@ extern errcode_t io_channel_set_options(io_channel channel,
 extern errcode_t io_channel_write_byte(io_channel channel, 
                                       unsigned long offset,
                                       int count, const void *data);
+extern errcode_t io_channel_read_blk64(io_channel channel,
+                                      unsigned long long block,
+                                      int count, void *data);
+extern errcode_t io_channel_write_blk64(io_channel channel,
+                                       unsigned long long block,
+                                       int count, const void *data);
 
 /* unix_io.c */
 extern io_manager unix_io_manager;
index e50d7e414bf759cd42091c000bb1485ce58d2c84..8d732530891f8dd0b3d4fbfb0d29c25a9f43dd45 100644 (file)
@@ -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);
+}