e4ba43dd5f
Ugh. I overlooked a weird corner case in rename's behavior that requires changes to the grm to support. POSIX's rename, which lfsr_rename is trying to match, supports renaming files over existing files, effectively removing the previous file during the rename. This is supported, even if the files are directories, but with the additional requirement that the previous directory is empty (matching the behavior of lfsr_remove). This creates a weird situation for littlefs. In order to remove directories in littlefs, we need to atomically remove both the dstart entry that reserves the directory's did and the directories entry in its parent. This is made possible by using the grm to mark one entry as pending removed while removing the other. But in order to rename atomically, we need to use the grm to mark the source of the rename as removed while creating/replacing the destination of the rename. So we end up needing two grms simultaneously. This is extra annoying because the niche case of renaming a directory over another empty directory is the only case where we need two grms, but this requirement almost doubles the grm size both in-ram and reserved in every mdir, from 11 bytes to 21 bytes, and increases the lfs_t size by 28 bytes. --- Anyways, this commit extends the grm to support up to two pending removes. Fortunately the implementation was simple since we already have a type field that can be extended, and grm operations just needed to be changed from if statements to for loops.