mirror of
https://github.com/littlefs-project/littlefs.git
synced 2025-12-01 12:20:02 +00:00
Reworked how unknown file types are handled
This changes how we approach unknown file types.
Before:
> Unknown file types are allowed and may leak resources if modified,
> so attempted modification (rename/remove) will error with
> LFS_ERR_NOTSUP.
Now:
> Unknown file types are only allowed in RDONLY mode. This avoids the
> whole leaking resources headache.
Additionally, unknown types are now mapped to LFS_TYPE_UNKNOWN, instead
of just being forwarded to the user. This allows us to add internal
types/tags to the LFSR_TAG_NAME type space without worrying about
conflicts with future types:
- reg -> LFS_TYPE_REG
- dir -> LFS_TYPE_DIR
- stickynote -> LFS_TYPE_STICKYNOTE
- everything else -> LFS_TYPE_UNKNOWN
Thinking about potential future types, it seems most (symlinks,
compressed files, etc) can be better implemented via custom attributes.
Using custom attributes doesn't mean the filesystem _can't_ inject
special behavior, and custom attributes allow for perfect backwards
compatibility.
So with future types less likely, forwarding type info to users is less
important (and potentially error prone). Instead, allowing on-disk +
internal types to be represented densely is much more useful.
And it avoids setting an upper bound on future types prematurely.
---
This also includes a minor rcompat/wcompat rework. Since we're probably
going to end up with 32-bit rcompat flags anyways, might as well make
them more human-readable (nibble-aligned):
LFS_RCOMPAT_NONSTANDARD 0x00000001 Non-standard filesystem format
LFS_RCOMPAT_WRONLY 0x00000002 Reading is disallowed
LFS_RCOMPAT_BMOSS 0x00000010 Files may use inlined data
LFS_RCOMPAT_BSPROUT 0x00000020 Files may use block pointers
LFS_RCOMPAT_BSHRUB 0x00000040 Files may use inlined btrees
LFS_RCOMPAT_BTREE 0x00000080 Files may use btrees
LFS_RCOMPAT_MMOSS 0x00000100 May use an inlined mdir
LFS_RCOMPAT_MSPROUT 0x00000200 May use an mdir pointer
LFS_RCOMPAT_MSHRUB 0x00000400 May use an inlined mtree
LFS_RCOMPAT_MTREE 0x00000800 May use an mdir btree
LFS_RCOMPAT_GRM 0x00001000 Global-remove in use
LFS_WCOMPAT_NONSTANDARD 0x00000001 Non-standard filesystem format
LFS_WCOMPAT_RDONLY 0x00000002 Writing is disallowed
LFS_WCOMPAT_REG 0x00000010 Regular file types in use
LFS_WCOMPAT_DIR 0x00000020 Directory file types in use
LFS_WCOMPAT_STICKYNOTE 0x00000040 Stickynote file types in use
LFS_WCOMPAT_GCKSUM 0x00001000 Global-checksum in use
---
Code changes:
code stack ctx
before: 35928 2440 640
after: 35924 (-0.0%) 2440 (+0.0%) 640 (+0.0%)
This commit is contained in:
@ -41,7 +41,8 @@ FLAGS = [
|
||||
('^', 'DIR', 0x20000000, "Type = directory" ),
|
||||
('^', 'STICKYNOTE',0x30000000, "Type = stickynote" ),
|
||||
('^', 'BOOKMARK', 0x40000000, "Type = bookmark" ),
|
||||
('^', 'TRAVERSAL', 0x90000000, "Type = traversal" ),
|
||||
('^', 'TRAVERSAL', 0x50000000, "Type = traversal" ),
|
||||
('^', 'UNKNOWN', 0x60000000, "Type = unknown" ),
|
||||
('o', 'UNFLUSH', 0x01000000, "File's data does not match disk" ),
|
||||
('o', 'UNSYNC', 0x02000000, "File's metadata does not match disk" ),
|
||||
('o', 'UNCREAT', 0x04000000, "File does not exist yet" ),
|
||||
@ -132,7 +133,8 @@ FLAGS = [
|
||||
('^', 'DIR', 0x20000000, "Type = directory" ),
|
||||
('^', 'STICKYNOTE',0x30000000, "Type = stickynote" ),
|
||||
('^', 'BOOKMARK', 0x40000000, "Type = bookmark" ),
|
||||
('^', 'TRAVERSAL', 0x90000000, "Type = traversal" ),
|
||||
('^', 'TRAVERSAL', 0x50000000, "Type = traversal" ),
|
||||
('^', 'UNKNOWN', 0x60000000, "Type = unknown" ),
|
||||
('t', 'TSTATE', 0x0000000f, "The traversal's current tstate" ),
|
||||
('^', 'MROOTANCHOR',
|
||||
0x00000000, "Tstate = mroot-anchor" ),
|
||||
@ -157,24 +159,24 @@ FLAGS = [
|
||||
0x00000001, "Non-standard filesystem format" ),
|
||||
('RCOMPAT', 'WRONLY',
|
||||
0x00000002, "Reading is disallowed" ),
|
||||
('RCOMPAT', 'GRM',
|
||||
0x00000004, "Global-remove in use" ),
|
||||
('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" ),
|
||||
0x00000010, "Files may use inlined data" ),
|
||||
('RCOMPAT', 'BSPROUT',
|
||||
0x00000200, "Files may use block pointers" ),
|
||||
0x00000020, "Files may use block pointers" ),
|
||||
('RCOMPAT', 'BSHRUB',
|
||||
0x00000400, "Files may use inlined btrees" ),
|
||||
0x00000040, "Files may use inlined btrees" ),
|
||||
('RCOMPAT', 'BTREE',
|
||||
0x00000800, "Files may use btrees" ),
|
||||
0x00000080, "Files may use btrees" ),
|
||||
('RCOMPAT', 'MMOSS',
|
||||
0x00000100, "May use an inlined mdir" ),
|
||||
('RCOMPAT', 'MSPROUT',
|
||||
0x00000200, "May use an mdir pointer" ),
|
||||
('RCOMPAT', 'MSHRUB',
|
||||
0x00000400, "May use an inlined mtree" ),
|
||||
('RCOMPAT', 'MTREE',
|
||||
0x00000800, "May use an mdir btree" ),
|
||||
('RCOMPAT', 'GRM',
|
||||
0x00001000, "Global-remove in use" ),
|
||||
('rcompat', 'OVERFLOW',
|
||||
0x80000000, "Can't represent all flags" ),
|
||||
|
||||
@ -183,8 +185,14 @@ FLAGS = [
|
||||
0x00000001, "Non-standard filesystem format" ),
|
||||
('WCOMPAT', 'RDONLY',
|
||||
0x00000002, "Writing is disallowed" ),
|
||||
('WCOMPAT', 'REG',
|
||||
0x00000010, "Regular file types in use" ),
|
||||
('WCOMPAT', 'DIR',
|
||||
0x00000020, "Directory file types in use" ),
|
||||
('WCOMPAT', 'STICKYNOTE',
|
||||
0x00000040, "Stickynote file types in use" ),
|
||||
('WCOMPAT', 'GCKSUM',
|
||||
0x00000004, "Global-checksum in use" ),
|
||||
0x00001000, "Global-checksum in use" ),
|
||||
('wcompat', 'OVERFLOW',
|
||||
0x80000000, "Can't represent all flags" ),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user