Changed type info to be retrieved from name tag instead of struct tag

Originally, I had type info encoded in the struct tag. This initially
made sense because the type info only directly impacts the struct tag.
However this was a case of focusing too much on the details instead of
the bigger picture.

A more file operations need to figure out the type of a file, but it's
only actually a small number of file operations that need to interact
with the file's structure. For the common case, providing the type of
the file early shortens operations by a full tag access.

Additionally, but storing the type in the file name tag, this opens up
the struct tag to use those bits for storing more struct descriptions.
This commit is contained in:
Christopher Haster
2018-07-09 12:51:31 -05:00
parent d7b0652936
commit c1103efb53
2 changed files with 88 additions and 120 deletions

5
lfs.h
View File

@@ -98,7 +98,7 @@ enum lfs_type {
// file types
LFS_TYPE_REG = 0x008,
LFS_TYPE_DIR = 0x010,
LFS_TYPE_SUPERBLOCK = 0x038,
LFS_TYPE_SUPERBLOCK = 0x042,
// internally used entry structures
LFS_STRUCT_CTZ = 0x001,
@@ -316,8 +316,8 @@ typedef struct lfs_mdir {
uint16_t count;
bool erased;
bool split;
lfs_globals_t globals;
bool stop_at_commit; // TODO hmmm
lfs_globals_t globals;
} lfs_mdir_t;
typedef struct lfs_cache {
@@ -352,7 +352,6 @@ typedef struct lfs_dir {
} lfs_dir_t;
typedef struct lfs_superblock {
lfs_block_t root[2];
char magic[8];
uint32_t version;