mirror of
https://github.com/littlefs-project/littlefs.git
synced 2025-12-26 09:08:30 +00:00
Switched to writing compat flags as le32s
Most of littlefs's metadata is encoded in leb128s now, with the
exception of tags (be16, sort of), revision counts (le32), cksums
(le32), and flags.
It makes sense for tags to be a special case, these are written and
rewritten _everywhere_, but less so for flags, which are only written to
the mroot and updated infrequently.
We might as well save a bit of code by reusing our le32 machinery.
---
This changes lfsr_format to just write out compat flags as le32s, saving
a tiny bit of code at the cost of a tiny bit of disk usage (the real
benefit being a tiny bit of code simplification):
code stack ctx
before: 37792 2608 620
after: 37772 (-0.1%) 2608 (+0.0%) 620 (+0.0%)
Compat already need to handle trailing zeros gracefully, so this doesn't
change anything at mount time.
Also had to switch from enums to #defines thanks to C's broken enums.
Wooh. We already use #defines for the other flags for this reason.
This commit is contained in:
@@ -148,32 +148,43 @@ FLAGS = [
|
||||
|
||||
# Read-compat flags
|
||||
('RCOMPAT', 'NONSTANDARD',
|
||||
0x0001, "Non-standard filesystem format" ),
|
||||
('RCOMPAT', 'WRONLY', 0x0002, "Reading is disallowed" ),
|
||||
('RCOMPAT', 'GRM', 0x0004, "May use a global-remove" ),
|
||||
('RCOMPAT', 'MMOSS', 0x0010, "May use an inlined mdir" ),
|
||||
('RCOMPAT', 'MSPROUT', 0x0020, "May use a single mdir pointer" ),
|
||||
('RCOMPAT', 'MSHRUB', 0x0040, "May use an inlined mtree" ),
|
||||
('RCOMPAT', 'MTREE', 0x0080, "May use an mdir btree" ),
|
||||
('RCOMPAT', 'BMOSS', 0x0100, "Files may use inlined data" ),
|
||||
('RCOMPAT', 'BSPROUT', 0x0200, "Files may use single block pointers" ),
|
||||
('RCOMPAT', 'BSHRUB', 0x0400, "Files may use inlined btrees" ),
|
||||
('RCOMPAT', 'BTREE', 0x0800, "Files may use btrees" ),
|
||||
|
||||
('rcompat', 'OVERFLOW',0x8000, "Can't represent all flags" ),
|
||||
0x00000001, "Non-standard filesystem format" ),
|
||||
('RCOMPAT', 'WRONLY',
|
||||
0x00000002, "Reading is disallowed" ),
|
||||
('RCOMPAT', 'GRM',
|
||||
0x00000004, "May use a global-remove" ),
|
||||
('RCOMPAT', 'MMOSS',
|
||||
0x00000010, "May use an inlined mdir" ),
|
||||
('RCOMPAT', 'MSPROUT',
|
||||
0x00000020, "May use an mdir pointer" ),
|
||||
('RCOMPAT', 'MSHRUB',
|
||||
0x00000040, "May use an inlined mtree" ),
|
||||
('RCOMPAT', 'MTREE',
|
||||
0x00000080, "May use an mdir btree" ),
|
||||
('RCOMPAT', 'BMOSS',
|
||||
0x00000100, "Files may use inlined data" ),
|
||||
('RCOMPAT', 'BSPROUT',
|
||||
0x00000200, "Files may use block pointers" ),
|
||||
('RCOMPAT', 'BSHRUB',
|
||||
0x00000400, "Files may use inlined btrees" ),
|
||||
('RCOMPAT', 'BTREE',
|
||||
0x00000800, "Files may use btrees" ),
|
||||
('rcompat', 'OVERFLOW',
|
||||
0x80000000, "Can't represent all flags" ),
|
||||
|
||||
# Write-compat flags
|
||||
('WCOMPAT', 'NONSTANDARD',
|
||||
0x0001, "Non-standard filesystem format" ),
|
||||
('WCOMPAT', 'RDONLY', 0x0002, "Writing is disallowed" ),
|
||||
|
||||
('wcompat', 'OVERFLOW',0x8000, "Can't represent all flags" ),
|
||||
0x00000001, "Non-standard filesystem format" ),
|
||||
('WCOMPAT', 'RDONLY',
|
||||
0x00000002, "Writing is disallowed" ),
|
||||
('wcompat', 'OVERFLOW',
|
||||
0x80000000, "Can't represent all flags" ),
|
||||
|
||||
# Optional-compat flags
|
||||
('OCOMPAT', 'NONSTANDARD',
|
||||
0x0001, "Non-standard filesystem format" ),
|
||||
|
||||
('ocompat', 'OVERFLOW',0x8000, "Can't represent all flags" ),
|
||||
0x00000001, "Non-standard filesystem format" ),
|
||||
('ocompat', 'OVERFLOW',
|
||||
0x80000000, "Can't represent all flags" ),
|
||||
]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user