From d8f930eeabe7c494d5f81a41a52da519617f66d8 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Tue, 7 Aug 2018 09:57:54 -0500 Subject: [PATCH] Modified CTZ struct type to make space for erased files in the future In v1, littlefs didn't trust blocks that were been previously erased and conservatively erased any blocks before writing to them. This was a part of the design since the beginning because of the complexity of managing erased blocks when we can lose power at any time. However, we theoretically could keep track of files that have been properly erased by marking them with an "erased bit". A file marked this way could be opened and appended to without needing to COW the last block. The requirement would be that the "erased bit" is cleared during a write, since a power-loss would require that littlefs no longer trust the erased state of the file. This commit just shuffles the struct types around to make space for an "erased bit" in the struct type field to be added in the future. This ordering also makes more sense, since there will likely be more file representations than directory representations on disk. --- lfs.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lfs.h b/lfs.h index df0927ed694..aa962620225 100644 --- a/lfs.h +++ b/lfs.h @@ -104,9 +104,9 @@ enum lfs_type { LFS_TYPE_HARDTAIL = 0x0c1, LFS_TYPE_CRC = 0x0f0, - LFS_TYPE_INLINESTRUCT = 0x040, - LFS_TYPE_CTZSTRUCT = 0x041, - LFS_TYPE_DIRSTRUCT = 0x042, + LFS_TYPE_DIRSTRUCT = 0x040, + LFS_TYPE_INLINESTRUCT = 0x041, + LFS_TYPE_CTZSTRUCT = 0x042, // internal chip sources LFS_FROM_REGION = 0x000,