Fixed missing erase during file relocation

This was an easy fix, but highlighted the fact that the current testing
framework doesn't detect when a block is written to without an
associated erase.

Added a quick solution that creates an empty file during an erase.
This commit is contained in:
Christopher Haster
2017-06-25 16:56:12 -05:00
parent a1138a41ce
commit 0e1022a86c
2 changed files with 25 additions and 5 deletions

8
lfs.c
View File

@@ -1196,6 +1196,14 @@ relocate:
return err;
}
err = lfs_bd_erase(lfs, nblock);
if (err) {
if (err == LFS_ERR_CORRUPT) {
goto relocate;
}
return err;
}
// either read from dirty cache or disk
for (lfs_off_t i = 0; i < file->off; i++) {
uint8_t data;