gc: Added LFS3_GC_ALL to make running all gc work easier
This is an alias for all possible gc work, which is a bit more complicated than you might think due to compile-time features (example: LFS3_GC_REPOPGBMAP). The intention is to make loops like the following easy to write: struct lfs3_fsinfo fsinfo; lfs3_fs_stat(&lfs3, &fsinfo) => 0; lfs3_trv_t trv; lfs3_trv_open(&lfs3, &trv, fsinfo.flags & LFS3_GC_ALL) => 0; ... It's possible to do this by explicitly setting all gc flags, but that requires quite a bit of knowledge from the user. Another option is allowing -1 for gc/traversal flags, but that loses assert protection against unknown/misplaced flags. --- This raises more questions about the prefix naming: it feels a bit weird to take LFS3_I_* flags, mask with LFS3_GC_* flags, and pass them as LFS3_T_* flags, but it gets the job done. Limiting LFS3_GC_ALL to the LFS3_GC_* namespace avoids issues with opt-out/mode flags such as LFS3_T_RDONLY, LFS3_T_MTREEONLY, etc. For this reason it probably doesn't make sense to add something similar to the other namespaces.
This commit is contained in:
@@ -369,6 +369,16 @@ enum lfs3_btype {
|
||||
#define LFS3_GC_CKMETA 0x00001000 // Check metadata checksums
|
||||
#define LFS3_GC_CKDATA 0x00002000 // Check metadata + data checksums
|
||||
|
||||
// an alias for all possible GC work
|
||||
#define LFS3_GC_ALL ( \
|
||||
LFS3_IFDEF_RDONLY(0, LFS3_GC_MKCONSISTENT) \
|
||||
| LFS3_IFDEF_RDONLY(0, LFS3_GC_REPOPLOOKAHEAD) \
|
||||
| LFS3_IFDEF_RDONLY(0, \
|
||||
LFS3_IFDEF_GBMAP(LFS3_GC_REPOPGBMAP, 0)) \
|
||||
| LFS3_IFDEF_RDONLY(0, LFS3_GC_COMPACTMETA) \
|
||||
| LFS3_GC_CKMETA \
|
||||
| LFS3_GC_CKDATA)
|
||||
|
||||
|
||||
// Configuration provided during initialization of the littlefs
|
||||
struct lfs3_cfg {
|
||||
|
||||
Reference in New Issue
Block a user