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" <tytso@mit.edu>
bitmap-optimize
Theodore Ts'o 2011-06-04 16:36:19 -04:00
parent 1e082c6209
commit 6220b6715f
1 changed files with 6 additions and 0 deletions

View File

@ -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;