diff --git a/lfs.c b/lfs.c index 54554859..b1851618 100644 --- a/lfs.c +++ b/lfs.c @@ -4416,20 +4416,7 @@ static int lfs_rawformat(lfs_t *lfs, const struct lfs_config *cfg) { return err; } - if (cfg->block_count == 0) { - // Attempt to read a (possibly) prior superblock - lfs_superblock_t superblock; - err = lfs_scan_for_superblock(lfs, &superblock); - if (err) { - goto cleanup; - } - lfs->block_count = superblock.block_count; - - err = lfs_validate_superblock(lfs, &superblock); - if (err) { - goto cleanup; - } - } + LFS_ASSERT(cfg->block_count != 0); // create free lookahead memset(lfs->free.buffer, 0, lfs->cfg->lookahead_size); diff --git a/tests/test_superblocks.toml b/tests/test_superblocks.toml index f9826a83..99e1dad0 100644 --- a/tests/test_superblocks.toml +++ b/tests/test_superblocks.toml @@ -5,29 +5,6 @@ code = ''' lfs_format(&lfs, cfg) => 0; ''' -# formatting from interpretting a previous superblock block_count -[cases.test_superblocks_format_unknown_block_count] -code = ''' - lfs_t lfs; - lfs_format(&lfs, cfg) => 0; - assert(lfs.block_count == cfg->block_count); - - memset(&lfs, 0, sizeof(lfs)); - struct lfs_config tweaked_cfg = *cfg; - tweaked_cfg.block_count = 0; - lfs_format(&lfs, &tweaked_cfg) => 0; - assert(lfs.block_count == cfg->block_count); -''' - -# formatting from interpretting a non-existent previous superblock block_count -[cases.test_superblocks_format_unknown_block_count_failure] -code = ''' - lfs_t lfs; - struct lfs_config tweaked_cfg = *cfg; - tweaked_cfg.block_count = 0; - lfs_format(&lfs, &tweaked_cfg) => LFS_ERR_CORRUPT; -''' - # mount/unmount [cases.test_superblocks_mount] code = '''