Added more block_size/count inference tests and fixed a couple bugs

- Need to drop cache during block_size search.

- Removed "Corrupted" messages when root is not found to avoid too much debug
  output. This also gets rid of a long-term point of confusion arround
  "Corrupted" messages on a mount that is intended to fail.
This commit is contained in:
Christopher Haster
2022-11-12 14:31:52 -06:00
parent c8bc6f96cd
commit fc10790eba
2 changed files with 373 additions and 60 deletions
+8 -2
View File
@@ -1299,8 +1299,10 @@ static lfs_stag_t lfs_dir_fetchmatch(lfs_t *lfs,
dir->rev = revs[(r+1)%2];
}
LFS_ERROR("Corrupted dir pair at {0x%"PRIx32", 0x%"PRIx32"}",
dir->pair[0], dir->pair[1]);
if (!lfs_pair_isnull(lfs->root)) {
LFS_ERROR("Corrupted dir pair at {0x%"PRIx32", 0x%"PRIx32"}",
dir->pair[0], dir->pair[1]);
}
return LFS_ERR_CORRUPT;
}
@@ -4231,6 +4233,10 @@ static int lfs_rawmount(lfs_t *lfs, const struct lfs_config *cfg) {
lfs->block_count /= lfs->block_size/lfs->erase_size;
}
// make sure cached data from a different block_size doesn't cause
// problems, we should never visit the same mdir twice here anyways
lfs_cache_drop(lfs, &lfs->rcache);
// scan directory blocks for superblock and any global updates
lfs_mdir_t dir = {.tail = {0, 1}};
lfs_block_t cycle = 0;