diff options
author | Christopher Haster <chaster@utexas.edu> | 2017-11-17 02:25:41 +0300 |
---|---|---|
committer | Christopher Haster <chaster@utexas.edu> | 2017-11-17 02:25:41 +0300 |
commit | 843e3c6c7544de3ebb03821514f9cb7b1135e8cf (patch) | |
tree | d9b674c9478455b07060afe5bba51e9ad5372874 /lfs.h | |
parent | 2612e1b3faaa72cd79343c2d43187aafa0492b76 (diff) |
Added sticky-bit for preventing file syncs after write errors
Short story, files are no longer committed to directories during
file sync/close if the last write did not complete successfully.
This avoids a set of interesting user-experience issues related
to the end-of-life behaviour of the filesystem.
As a filesystem approaches end-of-life, the chances of running into
LFS_ERR_NOSPC grows rather quickly. Since this condition occurs after
at the end of a devices life, it's likely that operating in these
conditions hasn't been tested thoroughly.
In the specific case of file-writes, you can hit an LFS_ERR_NOSPC after
parts of the file have been written out. If the program simply continues
and closes the file, the file is written out half completed. Since
littlefs has a strong garuntee the prevents half-writes, it's unlikely
this state of the file would be expected.
To make things worse, since close is also responsible for memory
cleanup, it's actually _impossible_ to continue working as it was
without leaking memory.
By prevent the file commits, end-of-life behaviour should at least retain
a previous copy of the filesystem without any surprises.
Diffstat (limited to 'lfs.h')
-rw-r--r-- | lfs.h | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -75,6 +75,7 @@ enum lfs_open_flags { LFS_F_DIRTY = 0x10000, // File does not match storage LFS_F_WRITING = 0x20000, // File has been written since last flush LFS_F_READING = 0x40000, // File has been read since last flush + LFS_F_ERRED = 0x80000, // An error occured during write }; // File seek flags |