Skip to content

Commit fe28ea0

Browse files
committed
Added internal check of data written to disk
Before, the littlefs relied on the underlying block device to report corruption that occurs when writing data to disk. This requirement is easy to miss or implement incorrectly, since the error detection is only required when a block becomes corrupted, which is very unlikely to happen until late in the block device's lifetime. The littlefs can detect corruption itself by reading back written data. This requires a bit of care to reuse the available buffers, and may rely on checksums to avoid additional RAM requirements. This does have a runtime penalty with the extra read operations, but should make the littlefs much more robust to different implementations.
1 parent 1eeb2a6 commit fe28ea0

File tree

5 files changed

+164
-100
lines changed

5 files changed

+164
-100
lines changed

emubd/lfs_emubd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ int lfs_emubd_prog(const struct lfs_config *cfg, lfs_block_t block,
161161
}
162162

163163
emu->stats.prog_count += 1;
164-
return (dat != data[0]) ? LFS_ERR_CORRUPT : 0;
164+
return 0;
165165
}
166166

167167
int lfs_emubd_erase(const struct lfs_config *cfg, lfs_block_t block) {

0 commit comments

Comments
 (0)