scripts: Added better branch cksum checks

If we're fetching branches anyways, we might as well check that the
checksums match. This helps protect against infinite loops in B-tree
branches.

Also fixed an issue where we weren't xoring perturb state on finding an
explicit trunk.

Note this is equivalent to LFS_M_CKFETCHES in lfs.c.

---

This doesn't mean we always need LFS_M_CKFETCHES. Our dbg scripts just
need to be a little bit tougher because 1. running tests with -j creates
wildly corrupted and entangled littlefs images, and 2. Rbyd.fetch is
almost too forgiving in choosing the nearest trunk.
This commit is contained in:
Christopher Haster
2024-11-07 14:07:27 -06:00
parent e3fdc3dbd7
commit 0260f0bcee
5 changed files with 100 additions and 79 deletions
+2 -1
View File
@@ -1003,7 +1003,8 @@ def main(disk, blocks=None, *,
if trunk and j_ + size > trunk:
eoff_ = j_ + size
eoff = eoff_
cksum = cksum_
cksum = cksum__ ^ (
0xfca42daf if perturb else 0)
trunk_ = trunk__
weight = weight_
trunk___ = 0