From c4fcc78814a8d4e0d4bae1ddc887575aca667975 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Wed, 24 Apr 2024 02:19:46 -0500 Subject: [PATCH] Tweaked file types/name tag encoding to be a bit less quirky The intention behind the quirky encoding was to leverage bit 1 to indicate if the underlying file type would be backed by the common file B-tree data structure. Looking forward, there may be several of these types, compressed files, contiguous files, etc, that for all intents and purposes are just normal files interpreted differently. But trying to leverage too many bits like this is probably going to give us a sparse, awkward, and confusing tag encoding, so I've reverted to a hopefully more normal encoding: LFSR_TAG_NAME 0x02tt v--- --1- -ttt tttt LFSR_TAG_NAME 0x0200 v--- --1- ---- ---- LFSR_TAG_REG 0x0201 v--- --1- ---- ---1 LFSR_TAG_DIR 0x0202 v--- --1- ---- --1- LFSR_TAG_SYMLINK* 0x0203 v--- --1- ---- --11 LFSR_TAG_BOOKMARK 0x0204 v--- --1- ---- -1-- LFSR_TAG_ORPHAN 0x0205 v--- --1- ---- -1-1 LFSR_TAG_COMPR* 0x0206 v--- --1- ---- -11- LFSR_TAG_CONTIG* 0x0207 v--- --1- ---- -111 * Hypothetical Note the carve-out for the hypothetical symlink tag. Symlinks are actually incredibly low in the priority list, but they are also the only current hypothetical file type that would need to be exposed to users. Grouping these up makes sense. This will get a bit messy if we ever end up with a 4th user-facing type, but there isn't any in POSIX at least (ignoring non-fs types, socket, fifo, character, block, etc). The gap also helps line things up so reg/orphan are a single bit flip, and the non-user facing types all share a bit. This had no impact on code size: code stack before: 33564 2816 after: 33564 (+0.0%) 2816 (+0.0%) --- lfs.c | 2 +- scripts/dbgbmap.py | 2 +- scripts/dbgbtree.py | 2 +- scripts/dbglfs.py | 2 +- scripts/dbgmtree.py | 2 +- scripts/dbgrbyd.py | 2 +- scripts/dbgtag.py | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lfs.c b/lfs.c index 3787a464..5b0a4bdc 100644 --- a/lfs.c +++ b/lfs.c @@ -733,8 +733,8 @@ enum lfsr_tag { LFSR_TAG_NAME = 0x0200, LFSR_TAG_REG = 0x0201, LFSR_TAG_DIR = 0x0202, - LFSR_TAG_ORPHAN = 0x0203, LFSR_TAG_BOOKMARK = 0x0204, + LFSR_TAG_ORPHAN = 0x0205, // struct tags LFSR_TAG_STRUCT = 0x0300, diff --git a/scripts/dbgbmap.py b/scripts/dbgbmap.py index e9d17c76..22041ab3 100755 --- a/scripts/dbgbmap.py +++ b/scripts/dbgbmap.py @@ -25,8 +25,8 @@ TAG_GRMDELTA = 0x0100 TAG_NAME = 0x0200 TAG_REG = 0x0201 TAG_DIR = 0x0202 -TAG_ORPHAN = 0x0203 TAG_BOOKMARK = 0x0204 +TAG_ORPHAN = 0x0205 TAG_STRUCT = 0x0300 TAG_DATA = 0x0300 TAG_BLOCK = 0x0304 diff --git a/scripts/dbgbtree.py b/scripts/dbgbtree.py index c002d7a8..4c8b380a 100755 --- a/scripts/dbgbtree.py +++ b/scripts/dbgbtree.py @@ -23,8 +23,8 @@ TAG_GRMDELTA = 0x0100 TAG_NAME = 0x0200 TAG_REG = 0x0201 TAG_DIR = 0x0202 -TAG_ORPHAN = 0x0203 TAG_BOOKMARK = 0x0204 +TAG_ORPHAN = 0x0205 TAG_STRUCT = 0x0300 TAG_DATA = 0x0300 TAG_BLOCK = 0x0304 diff --git a/scripts/dbglfs.py b/scripts/dbglfs.py index 48a6a6c8..4781f086 100755 --- a/scripts/dbglfs.py +++ b/scripts/dbglfs.py @@ -24,8 +24,8 @@ TAG_GRMDELTA = 0x0100 TAG_NAME = 0x0200 TAG_REG = 0x0201 TAG_DIR = 0x0202 -TAG_ORPHAN = 0x0203 TAG_BOOKMARK = 0x0204 +TAG_ORPHAN = 0x0205 TAG_STRUCT = 0x0300 TAG_DATA = 0x0300 TAG_BLOCK = 0x0304 diff --git a/scripts/dbgmtree.py b/scripts/dbgmtree.py index 7d87677a..dfb629e2 100755 --- a/scripts/dbgmtree.py +++ b/scripts/dbgmtree.py @@ -23,8 +23,8 @@ TAG_GRMDELTA = 0x0100 TAG_NAME = 0x0200 TAG_REG = 0x0201 TAG_DIR = 0x0202 -TAG_ORPHAN = 0x0203 TAG_BOOKMARK = 0x0204 +TAG_ORPHAN = 0x0205 TAG_STRUCT = 0x0300 TAG_DATA = 0x0300 TAG_BLOCK = 0x0304 diff --git a/scripts/dbgrbyd.py b/scripts/dbgrbyd.py index f469f253..a0be4d73 100755 --- a/scripts/dbgrbyd.py +++ b/scripts/dbgrbyd.py @@ -32,8 +32,8 @@ TAG_GRMDELTA = 0x0100 TAG_NAME = 0x0200 TAG_REG = 0x0201 TAG_DIR = 0x0202 -TAG_ORPHAN = 0x0203 TAG_BOOKMARK = 0x0204 +TAG_ORPHAN = 0x0205 TAG_STRUCT = 0x0300 TAG_DATA = 0x0300 TAG_BLOCK = 0x0304 diff --git a/scripts/dbgtag.py b/scripts/dbgtag.py index 11969544..a9bc28fa 100755 --- a/scripts/dbgtag.py +++ b/scripts/dbgtag.py @@ -21,8 +21,8 @@ TAG_GRMDELTA = 0x0100 TAG_NAME = 0x0200 TAG_REG = 0x0201 TAG_DIR = 0x0202 -TAG_ORPHAN = 0x0203 TAG_BOOKMARK = 0x0204 +TAG_ORPHAN = 0x0205 TAG_STRUCT = 0x0300 TAG_DATA = 0x0300 TAG_BLOCK = 0x0304