Reworked file flushing to allow cached data to remain in buffer

This is intended to enable lfsr_file_read to use the buffer as well.

This adds LFS_F_UNFLUSHED and internal lfsr_file_flush to manage buffer
flushing. This also results in a nice reorganization of lfsr_file_sync.

Of course, small file caching proves to be a big pain again, with
several subtle corner cases in truncate/fruncate that need to set the
LFS_F_UNFLUSHED flag so we fix small files in lfsr_file_sync.
This commit is contained in:
Christopher Haster
2023-12-16 15:57:25 -06:00
parent 161cd9e6da
commit 90a08cc944
2 changed files with 182 additions and 139 deletions
+3 -2
View File
@@ -165,8 +165,9 @@ enum lfs_open_flags {
#endif
// internally used flags
LFS_F_UNSYNCED = 0x010000, // File's metadata does not match storage
LFS_F_ERRORED = 0x020000, // An error occurred during write
LFS_F_UNFLUSHED = 0x010000, // File's data does not match storage
LFS_F_UNSYNCED = 0x020000, // File's metadata does not match storage
LFS_F_ERRORED = 0x040000, // An error occurred during write
};
// File seek flags