Added support for recursive removes in directories
"Recursion" here just refers to the ability to remove entries in a directory while iterating over it. This is very useful when you just want a directory gone, and can be extended to a "true" recursive remove straightforwardly. This mainly tests that mid/rid updates in opened mdirs are correct. To make this work, we need to update opened dirs differently than files, since opened dirs do not get marked as removed when its rid is removed and contain an additional position in the dir that needs to be updated. To keep track of the different types, littlefs now contains 2 linked-lists for opened mdirs. Maybe these should be correctly typed, but by hiding the specific types behind an array of mdir linked-lists, we can more efficiently iterate over both lists when necessary. We should probably compare this approach to the type-tagged approach in the previous littlefs implementation, but I think the idea of an array of type-hidden linked-lists just didn't come to me then. There was also a bit more room in the mdir structs to hide a 1-bit type field. The mdir structs here are getting pretty squeezed since they are used everywhere.
This commit is contained in:
@@ -420,7 +420,7 @@ typedef struct lfs_dir {
|
||||
|
||||
typedef struct lfsr_dir {
|
||||
lfsr_openedmdir_t mdir;
|
||||
lfs_off_t off;
|
||||
lfs_off_t pos;
|
||||
} lfsr_dir_t;
|
||||
|
||||
// littlefs file type
|
||||
@@ -500,8 +500,9 @@ typedef struct lfs {
|
||||
uint8_t grm[LFSR_GRM_DSIZE];
|
||||
uint8_t grmd[LFSR_GRM_DSIZE];
|
||||
|
||||
// linked-list of opened mdirs
|
||||
lfsr_openedmdir_t *opened;
|
||||
// linked-lists of opened mdirs, we keep a separate linked-list
|
||||
// for each type since these need to be handled a bit differently
|
||||
lfsr_openedmdir_t *opened[2];
|
||||
|
||||
#ifdef LFS_MIGRATE
|
||||
struct lfs1 *lfs1;
|
||||
|
||||
Reference in New Issue
Block a user