Reworked rcompat flags

Mainly to add LFS_RCOMPAT_MSPROUT. It makes sense that a littlefs driver
may not want to support mroot-inlined mdirs, and this flag would be the
only way to indicate that. (Currently inlined mdir -> mtree is one way,
but this may not always be the case.)

This also makes space for a couple planned features:

  LFS_RCOMPAT_NONSTANDARD  0x00000001  Non-standard filesystem format
  LFS_RCOMPAT_WRONLY*      0x00000002  Reading is disallowed
  LFS_RCOMPAT_GRM          0x00000004  May use a global-remove
  LFS_RCOMPAT_MSPROUT      0x00000010  May use an inlined mdir
  LFS_RCOMPAT_MLEAF        0x00000020  May use a single mdir pointer
  LFS_RCOMPAT_MSHRUB       0x00000040  May use an inlined mtree
  LFS_RCOMPAT_MTREE        0x00000080  May use an mdir btree
  LFS_RCOMPAT_BSPROUT      0x00000100  Files may use inlined data
  LFS_RCOMPAT_BLEAF        0x00000200  Files may use single block pointers
  LFS_RCOMPAT_BSHRUB       0x00000400  Files may use inlined btrees
  LFS_RCOMPAT_BTREE        0x00000800  Files may use btrees

  *Planned

I've gone ahead and included rcompat flags we reserve but don't
currently use (LFS_RCOMPAT_MSHRUB). It seems like a good idea to make
these reservations explicit. Though we should still prohibit their use
until there is a good reason, in case we want to repurpose these flags
in the future.

Code changes minimal (larger literal? compiler noise?):

           code          stack          ctx
  before: 37788           2608          620
  after:  37792 (+0.0%)   2608 (+0.0%)  620 (+0.0%)
This commit is contained in:
Christopher Haster
2025-01-09 18:23:55 -06:00
parent 5f6dbdcb14
commit af6ea39cca
2 changed files with 22 additions and 17 deletions
+13 -10
View File
@@ -13393,25 +13393,28 @@ static int lfs_deinit(lfs_t *lfs) {
//
enum lfsr_rcompat {
LFSR_RCOMPAT_NONSTANDARD = 0x0001, // Non-standard filesystem format
LFSR_RCOMPAT_MLEAF = 0x0002, // May use a single mdir pointer
LFSR_RCOMPAT_MTREE = 0x0008, // May use an mtree
LFSR_RCOMPAT_BSPROUT = 0x0010, // Files may use inlined data
LFSR_RCOMPAT_BLEAF = 0x0020, // Files may use single block pointers
LFSR_RCOMPAT_BSHRUB = 0x0040, // Files may use inlined btrees
LFSR_RCOMPAT_BTREE = 0x0080, // Files may use btrees
LFSR_RCOMPAT_GRM = 0x0100, // May use a global-remove
LFSR_RCOMPAT_GRM = 0x0004, // May use a global-remove
LFSR_RCOMPAT_MSPROUT = 0x0010, // May use an inlined mdir
LFSR_RCOMPAT_MLEAF = 0x0020, // May use a single mdir pointer
LFSR_RCOMPAT_MSHRUB = 0x0040, // May use an inlined mtree
LFSR_RCOMPAT_MTREE = 0x0080, // May use an mtree
LFSR_RCOMPAT_BSPROUT = 0x0100, // Files may use inlined data
LFSR_RCOMPAT_BLEAF = 0x0200, // Files may use single block pointers
LFSR_RCOMPAT_BSHRUB = 0x0400, // Files may use inlined btrees
LFSR_RCOMPAT_BTREE = 0x0800, // Files may use btrees
// internal
LFSR_rcompat_OVERFLOW = 0x8000, // Can't represent all flags
};
#define LFSR_RCOMPAT_COMPAT \
(LFSR_RCOMPAT_MLEAF \
(LFSR_RCOMPAT_GRM \
| LFSR_RCOMPAT_MSPROUT \
| LFSR_RCOMPAT_MLEAF \
| LFSR_RCOMPAT_MTREE \
| LFSR_RCOMPAT_BSPROUT \
| LFSR_RCOMPAT_BLEAF \
| LFSR_RCOMPAT_BSHRUB \
| LFSR_RCOMPAT_BTREE \
| LFSR_RCOMPAT_GRM)
| LFSR_RCOMPAT_BTREE)
enum lfsr_wcompat {
LFSR_WCOMPAT_NONSTANDARD = 0x0001, // Non-standard filesystem format