Skip to content

Commit

Permalink
Added internal check of data written to disk
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
geky committed Jun 28, 2017
1 parent 1eeb2a6 commit fe28ea0
Show file tree
Hide file tree
Showing 5 changed files with 164 additions and 100 deletions.
2 changes: 1 addition & 1 deletion emubd/lfs_emubd.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ int lfs_emubd_prog(const struct lfs_config *cfg, lfs_block_t block,
}

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

int lfs_emubd_erase(const struct lfs_config *cfg, lfs_block_t block) {
Expand Down
Loading

0 comments on commit fe28ea0

Please sign in to comment.