mirror of
				https://github.com/eledio-devices/thirdparty-littlefs.git
				synced 2025-10-31 16:14:16 +01:00 
			
		
		
		
	Added better handling for metadata pairs
The core algorithim that backs this filesystem's goal of fault tolerance is the alternating of "metadata pairs". Backed by a simple core function for reading and writing, makes heavy use of c99 designated initializers for passing info about multiple chunks in an erase block.
This commit is contained in:
		| @@ -13,6 +13,7 @@ | ||||
| #include <stdio.h> | ||||
| #include <limits.h> | ||||
| #include <dirent.h> | ||||
| #include <sys/stat.h> | ||||
|  | ||||
|  | ||||
| // Block device emulated on existing filesystem | ||||
| @@ -168,11 +169,19 @@ lfs_error_t lfs_emubd_erase(lfs_emubd_t *emu, | ||||
|     // Iterate and erase blocks | ||||
|     while (size > 0) { | ||||
|         snprintf(emu->child, LFS_NAME_MAX, "%d", ino); | ||||
|         int err = unlink(emu->path); | ||||
|         struct stat st; | ||||
|         int err = stat(emu->path, &st); | ||||
|         if (err && errno != ENOENT) { | ||||
|             return -errno; | ||||
|         } | ||||
|  | ||||
|         if (!err && S_ISREG(st.st_mode)) { | ||||
|             int err = unlink(emu->path); | ||||
|             if (err) { | ||||
|                 return -errno; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         size -= emu->info.erase_size; | ||||
|         ino += 1; | ||||
|         off = 0; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user