Replaced rattr.u.etc with rattr relevant types

This does a couple things:

- Makes attr-lists a bit more self-documenting.

- Adds a bit more type-safety. The LFSR_RATTR_* macros should be able to
  reject types that don't match the expected encoding.

- Makes it easier to adjust dsize estimates at one location.

  Specifically, this makes it harder to forget bptr's LFSR_BPTR_DSIZE.

---

Surprisingly this did have a small impact on code size. I'm not entirely
sure why, but considering how much of the codebase this touches I'm just
going to chalk this up to compiler noise:

           code          stack          ctx
  before: 35488           2440          636
  after:  35536 (+0.1%)   2440 (+0.0%)  636 (+0.0%)

lfsr_file_carve seems the hardest hit:

  function (0 added, 0 removed)      osize    nsize    dsize
  lfsr_file_open                        16       20       +4 (+25.0%)
  lfsr_file_carve                     1316     1356      +40 (+3.0%)
  lfsr_remove                          408      412       +4 (+1.0%)
  TOTAL                              35488    35536      +48 (+0.1%)
This commit is contained in:
Christopher Haster
2025-02-12 13:49:38 -06:00
parent d806e7e323
commit 91341a4c48
6 changed files with 317 additions and 313 deletions
+5 -6
View File
@@ -546,8 +546,7 @@ code = '''
lfsr_mount(&lfs, LFS_M_RDWR, CFG) => 0;
lfsr_mdir_commit(&lfs, &lfs.mroot, LFSR_RATTRS(
LFSR_RATTR(
LFSR_TAG_RM | LFSR_TAG_MAGIC, 0,
NULL, 0))) => 0;
LFSR_TAG_RM | LFSR_TAG_MAGIC, 0))) => 0;
lfsr_unmount(&lfs) => 0;
// mount should now fail
@@ -981,11 +980,11 @@ code = '''
// is not a user API
lfsr_mount(&lfs, LFS_M_RDWR, CFG) => 0;
lfsr_mdir_commit(&lfs, &lfs.mroot, LFSR_RATTRS(
LFSR_RATTR(
LFSR_RATTR_GEOMETRY(
LFSR_TAG_GEOMETRY, 0,
(&(lfsr_geometry_t){
INC_BLOCK_SIZE,
BLOCK_COUNT}), LFSR_GEOMETRY_DSIZE))) => 0;
BLOCK_COUNT})))) => 0;
lfsr_unmount(&lfs) => 0;
// mount should now fail
@@ -1008,11 +1007,11 @@ code = '''
// is not a user API
lfsr_mount(&lfs, LFS_M_RDWR, CFG) => 0;
lfsr_mdir_commit(&lfs, &lfs.mroot, LFSR_RATTRS(
LFSR_RATTR(
LFSR_RATTR_GEOMETRY(
LFSR_TAG_GEOMETRY, 0,
(&(lfsr_geometry_t){
BLOCK_SIZE,
INC_BLOCK_COUNT}), LFSR_GEOMETRY_DSIZE))) => 0;
INC_BLOCK_COUNT})))) => 0;
lfsr_unmount(&lfs) => 0;
// mount should now fail