diff options
author | Brian Pugh <bnp117@gmail.com> | 2023-08-21 00:10:12 +0300 |
---|---|---|
committer | Brian Pugh <bnp117@gmail.com> | 2023-08-21 00:10:12 +0300 |
commit | 23089d5758b2a38ffa45028e446de292791272ff (patch) | |
tree | a203bd262b64e8d656a819c328bab3a45f612cf3 | |
parent | d6098bd3cef6ba0f3b24aac6643fc97959e3d418 (diff) |
remove previous block_count detection from lfs_format
-rw-r--r-- | lfs.c | 15 | ||||
-rw-r--r-- | tests/test_superblocks.toml | 23 |
2 files changed, 1 insertions, 37 deletions
@@ -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 f9826a8..99e1dad 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 = ''' |