Added the internal meta-directory structure

Similarly to the internal "meta-attributes", I was finding quite a bit
of need for an internal structure that mirrors the user-facing directory
structure for when I need to do an operation on a metadata-pair, but
don't need all of the state associated with a fully iterable directory
chain.

lfs_mdir_t - meta-directory, describes a single metadata-pair
lfs_dir_t  - directory, describes an iterable directory chain

While it may seem complex to have all these structures lying around,
they only complicate the code at compile time. To the machine, any
number of nested structures all looks the same.
This commit is contained in:
Christopher Haster
2018-05-29 01:11:26 -05:00
parent eaa9220aad
commit f458da4b7c
2 changed files with 98 additions and 104 deletions

18
lfs.h
View File

@@ -276,7 +276,7 @@ typedef struct lfs_mattr {
lfs_block_t block;
lfs_off_t off;
} d;
struct lfs_dir *dir;
struct lfs_mdir *dir;
} u;
} lfs_mattr_t;
@@ -307,13 +307,8 @@ typedef struct lfs_file {
lfs_mattrlist_t *attrs;
} lfs_file_t;
typedef struct lfs_dir {
struct lfs_dir *next;
typedef struct lfs_mdir {
lfs_block_t pair[2];
uint16_t id;
uint16_t pos;
lfs_block_t head[2];
lfs_block_t tail[2];
uint32_t rev;
lfs_off_t off;
@@ -323,6 +318,15 @@ typedef struct lfs_dir {
bool split;
bool stop_at_commit; // TODO hmmm
int16_t moveid;
} lfs_mdir_t;
typedef struct lfs_dir {
struct lfs_dir *next;
struct lfs_mdir m;
lfs_block_t head[2];
uint16_t id;
lfs_off_t pos;
} lfs_dir_t;
typedef struct lfs_superblock {