mirror of
				https://github.com/eledio-devices/thirdparty-littlefs.git
				synced 2025-10-31 00:32:38 +01:00 
			
		
		
		
	Revisited xored-globals and related logic
Added separate bit for "hasmove", which means we don't need to check the move id, and allows us to add more sync-related global states in the future, as long as they never happen simultaneously (such as orphans and moves). Also refactored some of the logic and removed the union in the global structure, which didn't really add anything of value.
This commit is contained in:
		
							
								
								
									
										23
									
								
								lfs.h
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								lfs.h
									
									
									
									
									
								
							| @@ -290,20 +290,6 @@ typedef struct lfs_cache { | ||||
|     uint8_t *buffer; | ||||
| } lfs_cache_t; | ||||
|  | ||||
| typedef union lfs_global { | ||||
|     uint32_t u32[3]; | ||||
|     struct { | ||||
|         lfs_block_t movepair[2]; | ||||
|         uint16_t moveid; | ||||
|         uint8_t deorphaned; | ||||
|     } l; | ||||
|     struct { | ||||
|         lfs_block_t movepair[2]; | ||||
|         uint16_t moveid; | ||||
|         uint8_t orphans; | ||||
|     } g; | ||||
| } lfs_global_t; | ||||
|  | ||||
| typedef struct lfs_mdir { | ||||
|     lfs_block_t pair[2]; | ||||
|     uint32_t rev; | ||||
| @@ -373,8 +359,13 @@ typedef struct lfs { | ||||
|     } *mlist; | ||||
|     uint32_t seed; | ||||
|  | ||||
|     lfs_global_t globals; | ||||
|     lfs_global_t locals; | ||||
|     struct lfs_globals { | ||||
|         lfs_block_t pair[2]; | ||||
|         uint16_t id; | ||||
|         bool hasmove; | ||||
|         uint8_t orphans; | ||||
|     } globals, locals; | ||||
|  | ||||
|     struct lfs_free { | ||||
|         lfs_block_t off; | ||||
|         lfs_block_t size; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user