From: Theodore Ts'o Date: Sat, 4 Jun 2011 20:36:19 +0000 (-0400) Subject: libext2fs: require cluster size == block_size when opening a !bigalloc fs X-Git-Tag: v1.42-WIP-0702~32^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6220b6715f4900bbcfa04ef3b81ccf48b2d21825;p=thirdparty%2Fe2fsprogs.git libext2fs: require cluster size == block_size when opening a !bigalloc fs In ext2fs_open() check to make sure the cluster size superblock field is the same as the block size field when the bigalloc feature is not set. This is necessary since we will start introducing calculations based on the cluster size field. Signed-off-by: "Theodore Ts'o" --- diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c index a20b923a0..f87c17170 100644 --- a/lib/ext2fs/openfs.c +++ b/lib/ext2fs/openfs.c @@ -239,6 +239,12 @@ errcode_t ext2fs_open2(const char *name, const char *io_options, retval = EXT2_ET_CORRUPT_SUPERBLOCK; goto cleanup; } + if (!EXT2_HAS_RO_COMPAT_FEATURE(fs->super, + EXT4_FEATURE_RO_COMPAT_BIGALLOC) && + (fs->super->s_log_block_size != fs->super->s_log_cluster_size)) { + retval = EXT2_ET_CORRUPT_SUPERBLOCK; + goto cleanup; + } fs->blocksize = EXT2_BLOCK_SIZE(fs->super); if (EXT2_INODE_SIZE(fs->super) < EXT2_GOOD_OLD_INODE_SIZE) { retval = EXT2_ET_CORRUPT_SUPERBLOCK;