Skip to content

Commit 58f3bb1

Browse files
authored
Merge pull request #37 from jrast/patch-1
Added a note about the callback functions
2 parents 1552246 + f72f6d6 commit 58f3bb1

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,17 @@ All littlefs have the potential to return a negative error code. The errors
115115
can be either one of those found in the `enum lfs_error` in [lfs.h](lfs.h),
116116
or an error returned by the user's block device operations.
117117
118-
It should also be noted that the current implementation of littlefs doesn't
119-
really do anything to ensure that the data written to disk is machine portable.
120-
This is fine as long as all of the involved machines share endianness
121-
(little-endian) and don't have strange padding requirements.
118+
In the configuration struct, the `prog` and `erase` function provided by the
119+
user may return a `LFS_ERR_CORRUPT` error if the implementation already can
120+
detect corrupt blocks. However, the wear leveling does not depend on the return
121+
code of these functions, instead all data is read back and checked for
122+
integrity.
123+
124+
If your storage caches writes, make sure that the provided `sync` function
125+
flushes all the data to memory and ensures that the next read fetches the data
126+
from memory, otherwise data integrity can not be guaranteed. If the `write`
127+
function does not perform caching, and therefore each `read` or `write` call
128+
hits the memory, the `sync` function can simply return 0.
122129
123130
## Reference material
124131

0 commit comments

Comments
 (0)