Avoided issue with tail deletions by tossing out-of-bound lookups early

This commit is contained in:
Christopher Haster
2022-12-31 03:47:21 -06:00
parent 5d9e7c8e86
commit 22879c1cbb
2 changed files with 47 additions and 60 deletions
+7
View File
@@ -1216,6 +1216,13 @@ static int lfs_rbyd_fetch(lfs_t *lfs,
static lfs_srtag_t lfs_rbyd_lookup(lfs_t *lfs, const lfs_rbyd_t *rbyd,
lfs_rtag_t tag, lfs_off_t *off, lfs_size_t *size) {
printf("lookup(%08x)\n", tag);
// TODO is this true?
// check for out-of-bound ids here, otherwise we have issues determining
// the found id
if (lfs_rtag_id(tag) >= rbyd->count+1) {
return LFS_ERR_NOENT;
}
tryagain:;
// no trunk yet?
lfs_off_t branch = rbyd->trunk;