Added mount-time LFS_M_FLUSH/SYNC

These simply imply LFS_O_FLUSH/SYNC on all open writable files.
LFS_M_SYNC is equivalent to MS_SYNCHRONOUS in Linux/etc, while
LFS_M_FLUSH is just provided for consistency.

As pure conveniences, these may seem a bit out of scope for littlefs,
except they are _very_ cheap:

           code          stack
  before: 36356           2664
  after:  36356 (+0.0%)   2664 (+0.0%)

Ok, they're not _completely_ free! It just turns out they cost 8 bytes,
and a bit of simplification around flag checking in lfsr_mount saved
8 bytes:

                  code          stack
  before:        36356           2664
  m_flush/sync:  36364 (+0.0%)   2664 (+0.0%)
  mount-no-mask: 36356 (+0.0%)   2664 (+0.0%)
This commit is contained in:
Christopher Haster
2024-07-26 15:48:07 -05:00
parent e676bb225c
commit b37bff377b
4 changed files with 166 additions and 97 deletions
+7 -1
View File
@@ -14,12 +14,16 @@ code = '''
[cases.test_mount_flags]
defines.RDONLY = [false, true]
defines.CKPROGS = [false, true]
defines.FLUSH = [false, true]
defines.SYNC = [false, true]
code = '''
lfs_t lfs;
lfsr_format(&lfs, CFG) => 0;
lfsr_mount(&lfs,
((RDONLY) ? LFS_M_RDONLY : LFS_M_RDWR)
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
| ((CKPROGS) ? LFS_M_CKPROGS : 0)
| ((FLUSH) ? LFS_M_FLUSH : 0)
| ((SYNC) ? LFS_M_SYNC : 0),
CFG) => 0;
struct lfs_fsinfo fsinfo;
@@ -27,6 +31,8 @@ code = '''
assert(fsinfo.flags == (
((RDONLY) ? LFS_I_RDONLY : 0)
| ((CKPROGS) ? LFS_I_CKPROGS : 0)
| ((FLUSH) ? LFS_I_FLUSH : 0)
| ((SYNC) ? LFS_I_SYNC : 0)
| LFS_I_CANLOOKAHEAD
| LFS_I_UNCOMPACTED));