From 63c9bcbe0bf8c1e15dcba334890d20a16b1156f7 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Tue, 28 May 2019 11:35:22 -0500 Subject: [PATCH] Fixed missing cache flush in lfs_migrate The data written to the prog cache would make littlefs internally consistent, but because this was never written to disk, the filesystem would become unmountable. Unfortunately, this wasn't found during testing because caches automatically flush if data is written up to a program boundary (maybe this was a mistake?). Found by rojer --- lfs.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lfs.c b/lfs.c index a12fdcff..7bd63e5a 100644 --- a/lfs.c +++ b/lfs.c @@ -4399,6 +4399,11 @@ int lfs_migrate(lfs_t *lfs, const struct lfs_config *cfg) { goto cleanup; } } + + err = lfs_bd_flush(lfs, &lfs->pcache, &lfs->rcache, true); + if (err) { + goto cleanup; + } } // Create new superblock. This marks a successful migration!