Skip to content

Commit

Permalink
Tweaked file types/name tag encoding to be a bit less quirky
Browse files Browse the repository at this point in the history
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           2832
  after:  33564 (+0.0%)   2832 (+0.0%)
  • Loading branch information
geky committed Apr 24, 2024
1 parent 956d67a commit 210375e
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion scripts/dbgbmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
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
Expand Down
2 changes: 1 addition & 1 deletion scripts/dbgbtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
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
Expand Down
2 changes: 1 addition & 1 deletion scripts/dbglfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
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
Expand Down
2 changes: 1 addition & 1 deletion scripts/dbgmtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
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
Expand Down
2 changes: 1 addition & 1 deletion scripts/dbgrbyd.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
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
Expand Down
2 changes: 1 addition & 1 deletion scripts/dbgtag.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
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
Expand Down

0 comments on commit 210375e

Please sign in to comment.