Allowed modification of unknown file types

This drops the requirement that all file types are introduced with a
related wcompat flag. Instead, the wcompat flag is only required if
modification _would_ leak resources, and we treat unknown file types as
though they are regular files.

This allows modification of unknown file types without the risk of
breaking anything.

To compare with before the unknown-type rework:

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 allowed but must not leak resources if
> modified. If an unknown file type would leak resources, it should set
> a related wcompat flag to only allow mounting RDONLY.

Note this includes directories, which can leak bookmarks if removed, so
filesystems using directories should set the LFSR_WCOMPAT_DIR flag.

But we no longer need the LFSR_WCOMPAT_REG/LFSR_WCOMPAT_STICKYNOTE
flags.

---

The real tricky part was getting lfsr_rename to work with unknown types,
as this broke the invariant that we only ever commit tags we know about.

Fixing this required:

- Fetching the non-unknown-mapped tag in lfsr_rename

- Mapping all name tags to LFSR_TAG_NAME in lfsr_rbyd_appendrattr_

- Adopting LFSR_RATTR_NAME for bookmark name tags

  This was broken by the above lfsr_rbyd_appendrattr_ change, but it's
  probably good to handle these the same as other name tags anyways.

This adds a bit of code, but not enough that I think this isn't worth
it (or worth a build-time option):

           code          stack          ctx
  before: 35924           2440          640
  after:  35992 (+0.0%)   2440 (+0.0%)  640 (+0.0%)
This commit is contained in:
Christopher Haster
2025-04-24 14:00:12 -05:00
parent 09c3749d7a
commit a34bcdb5bf
4 changed files with 1246 additions and 47 deletions

View File

@@ -185,12 +185,8 @@ 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" ),
0x00000010, "Directory file types in use" ),
('WCOMPAT', 'GCKSUM',
0x00001000, "Global-checksum in use" ),
('wcompat', 'OVERFLOW',