diff options
author | Christopher Haster <chaster@utexas.edu> | 2018-09-11 06:07:59 +0300 |
---|---|---|
committer | Christopher Haster <chaster@utexas.edu> | 2018-10-18 18:00:49 +0300 |
commit | 5eeeb9d6ac0e71f182c107a540939a56b26bb957 (patch) | |
tree | c137bd135d09b997c7988b20e906a4cf9103432d /lfs.h | |
parent | 617dd87621e7e5120427fd0887dbfcdc8af525ac (diff) |
Revisited some generic concepts, callbacks, and some reorganization
- Callbacks for get/match, this does have a code cost, but allows more
code reuse, which almost balances out the code cost, but also reduces
maintenance and increased flexibility. Also callbacks may be able to
be gc-ed in some cases.
- Consistent struct vs _t usage, _t for external-facing struct that
shouldn't be messed with outside the library. structs for external and
internal structs where anyone with access is allowed to modify.
- Reorganized several high-level function groups
- Inlined structures that didn't need separate definitions in header
Diffstat (limited to 'lfs.h')
-rw-r--r-- | lfs.h | 44 |
1 files changed, 18 insertions, 26 deletions
@@ -113,7 +113,7 @@ enum lfs_type { LFS_FROM_REGION = 0x000, LFS_FROM_DISK = 0x200, LFS_FROM_MOVE = 0x0c1, - LFS_FROM_ATTRS = 0x0c2, + LFS_FROM_USERATTRS = 0x0c2, LFS_FROM_SUPERBLOCK = 0x0c3, }; @@ -284,13 +284,7 @@ struct lfs_file_config { }; -/// littlefs data structures /// -typedef struct lfs_mattr { - int32_t tag; - const void *buffer; - const struct lfs_mattr *next; -} lfs_mattr_t; - +/// internal littlefs data structures /// typedef struct lfs_cache { lfs_block_t block; lfs_off_t off; @@ -324,13 +318,7 @@ typedef struct lfs_mdir { lfs_global_t locals; } lfs_mdir_t; -typedef struct lfs_mlist { - struct lfs_mlist *next; - uint16_t id; - uint8_t type; - lfs_mdir_t m; -} lfs_mlist_t; - +// littlefs directory type typedef struct lfs_dir { struct lfs_dir *next; uint16_t id; @@ -341,6 +329,7 @@ typedef struct lfs_dir { lfs_block_t head[2]; } lfs_dir_t; +// littlefs file type typedef struct lfs_file { struct lfs_file *next; uint16_t id; @@ -373,26 +362,29 @@ typedef struct lfs_superblock { lfs_size_t inline_max; } lfs_superblock_t; -typedef struct lfs_free { - lfs_block_t off; - lfs_block_t size; - lfs_block_t i; - lfs_block_t ack; - uint32_t *buffer; -} lfs_free_t; - -// The littlefs type +// The littlefs filesystem type typedef struct lfs { lfs_cache_t rcache; lfs_cache_t pcache; lfs_block_t root[2]; - lfs_mlist_t *mlist; + struct lfs_mlist { + struct lfs_mlist *next; + uint16_t id; + uint8_t type; + lfs_mdir_t m; + } *mlist; uint32_t seed; lfs_global_t globals; lfs_global_t locals; - lfs_free_t free; + struct lfs_free { + lfs_block_t off; + lfs_block_t size; + lfs_block_t i; + lfs_block_t ack; + uint32_t *buffer; + } free; const struct lfs_config *cfg; lfs_size_t block_size; |