From: Theodore Ts'o Date: Fri, 16 Dec 2011 16:24:23 +0000 (-0500) Subject: libext2fs: add default_bitmap_type to the ext2_filsys structure X-Git-Tag: v1.42.1~39 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=67861e5bf3ae177b14d34846218fcdfdeee805a6;p=thirdparty%2Fe2fsprogs.git libext2fs: add default_bitmap_type to the ext2_filsys structure This allows a program to control the bitmap backend implementation that will get used without needing to change the current library API. Signed-off-by: "Theodore Ts'o" --- diff --git a/lib/ext2fs/bitmaps.c b/lib/ext2fs/bitmaps.c index e518295df..840219172 100644 --- a/lib/ext2fs/bitmaps.c +++ b/lib/ext2fs/bitmaps.c @@ -67,9 +67,9 @@ errcode_t ext2fs_allocate_inode_bitmap(ext2_filsys fs, /* Are we permitted to use new-style bitmaps? */ if (fs->flags & EXT2_FLAG_64BITS) return (ext2fs_alloc_generic_bmap(fs, - EXT2_ET_MAGIC_INODE_BITMAP64, - EXT2FS_BMAP64_BITARRAY, - start, end, real_end, descr, ret)); + EXT2_ET_MAGIC_INODE_BITMAP64, + fs->default_bitmap_type, + start, end, real_end, descr, ret)); /* Otherwise, check to see if the file system is small enough * to use old-style 32-bit bitmaps */ @@ -99,9 +99,9 @@ errcode_t ext2fs_allocate_block_bitmap(ext2_filsys fs, if (fs->flags & EXT2_FLAG_64BITS) return (ext2fs_alloc_generic_bmap(fs, - EXT2_ET_MAGIC_BLOCK_BITMAP64, - EXT2FS_BMAP64_BITARRAY, - start, end, real_end, descr, ret)); + EXT2_ET_MAGIC_BLOCK_BITMAP64, + fs->default_bitmap_type, + start, end, real_end, descr, ret)); if ((end > ~0U) || (real_end > ~0U)) return EXT2_ET_CANT_USE_LEGACY_BITMAPS; @@ -143,7 +143,7 @@ errcode_t ext2fs_allocate_subcluster_bitmap(ext2_filsys fs, * (__u64) fs->group_desc_count)-1 + start; retval = ext2fs_alloc_generic_bmap(fs, EXT2_ET_MAGIC_BLOCK_BITMAP64, - EXT2FS_BMAP64_BITARRAY, start, + fs->default_bitmap_type, start, end, real_end, descr, &bmap); if (retval) return retval; diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h index 227ee5829..d90a8b18b 100644 --- a/lib/ext2fs/ext2fs.h +++ b/lib/ext2fs/ext2fs.h @@ -244,10 +244,12 @@ struct struct_ext2_filsys { __u32 umask; time_t now; int cluster_ratio_bits; + __u16 default_bitmap_type; + __u16 pad; /* * Reserved for future expansion */ - __u32 reserved[6]; + __u32 reserved[5]; /* * Reserved for the use of the calling application. @@ -286,6 +288,12 @@ struct struct_ext2_filsys { #include #endif +/* + * 64-bit bitmap backend types + */ + +#define EXT2FS_BMAP64_BITARRAY 1 + /* * Return flags for the block iterator functions */ diff --git a/lib/ext2fs/ext2fsP.h b/lib/ext2fs/ext2fsP.h index 82e1ba0e5..729d5c537 100644 --- a/lib/ext2fs/ext2fsP.h +++ b/lib/ext2fs/ext2fsP.h @@ -109,8 +109,6 @@ extern void ext2fs_numeric_progress_close(ext2_filsys fs, * 64-bit bitmap support */ -#define EXT2FS_BMAP64_BITARRAY 1 - extern errcode_t ext2fs_alloc_generic_bmap(ext2_filsys fs, errcode_t magic, int type, __u64 start, __u64 end, __u64 real_end, diff --git a/lib/ext2fs/gen_bitmap64.c b/lib/ext2fs/gen_bitmap64.c index 4dc4e0824..e1b4f420b 100644 --- a/lib/ext2fs/gen_bitmap64.c +++ b/lib/ext2fs/gen_bitmap64.c @@ -88,6 +88,9 @@ errcode_t ext2fs_alloc_generic_bmap(ext2_filsys fs, errcode_t magic, struct ext2_bitmap_ops *ops; errcode_t retval; + if (!type) + type = EXT2FS_BMAP64_BITARRAY; + switch (type) { case EXT2FS_BMAP64_BITARRAY: ops = &ext2fs_blkmap64_bitarray;