From ae9e37cd114385764864518057ff854b3f335440 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Sat, 4 Jun 2011 16:40:26 -0400 Subject: [PATCH] libext2fs: change EXT2_MAX_BLOCKS_PER_GROUP() to be cluster size aware Change the EXT2_MAX_BLOCKS_PER_GROUP so that it takes the cluster size into account. This way we can open bigalloc file systems without ext2fs_open() thinking that they are corrupt. Signed-off-by: "Theodore Ts'o" --- lib/ext2fs/ext2_fs.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/ext2fs/ext2_fs.h b/lib/ext2fs/ext2_fs.h index a6c70de..2d96091 100644 --- a/lib/ext2fs/ext2_fs.h +++ b/lib/ext2fs/ext2_fs.h @@ -225,9 +225,13 @@ struct ext2_dx_countlimit { #define EXT2_BLOCKS_PER_GROUP(s) (EXT2_SB(s)->s_blocks_per_group) #define EXT2_INODES_PER_GROUP(s) (EXT2_SB(s)->s_inodes_per_group) +#define EXT2_CLUSTERS_PER_GROUP(s) (EXT2_SB(s)->s_clusters_per_group) #define EXT2_INODES_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s)/EXT2_INODE_SIZE(s)) /* limits imposed by 16-bit value gd_free_{blocks,inode}_count */ -#define EXT2_MAX_BLOCKS_PER_GROUP(s) ((1 << 16) - 8) +#define EXT2_MAX_BLOCKS_PER_GROUP(s) (((1 << 16) - 8) * \ + (EXT2_CLUSTER_SIZE(s) / \ + EXT2_BLOCK_SIZE(s))) +#define EXT2_MAX_CLUSTERS_PER_GROUP(s) ((1 << 16) - 8) #define EXT2_MAX_INODES_PER_GROUP(s) ((1 << 16) - EXT2_INODES_PER_BLOCK(s)) #ifdef __KERNEL__ #define EXT2_DESC_PER_BLOCK(s) (EXT2_SB(s)->s_desc_per_block) -- 1.8.3.1