mirror of
				https://github.com/eledio-devices/thirdparty-littlefs.git
				synced 2025-10-31 08:42:40 +01:00 
			
		
		
		
	Moved sanity check in lfs_format after compaction
After a bit of tweaking in 9dde5c7 to write out all superblocks during lfs_format, additional writes were added after the sanity checking normally done at the end. This turned out to be a problem when porting littlefs, as it makes it easy for addressing issues to not get caught during lfs_format. Found by marekr, tristanclare94, and mjs513
This commit is contained in:
		
							
								
								
									
										12
									
								
								lfs.c
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								lfs.c
									
									
									
									
									
								
							| @@ -3616,12 +3616,6 @@ static int lfs_rawformat(lfs_t *lfs, const struct lfs_config *cfg) { | |||||||
|             goto cleanup; |             goto cleanup; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         // sanity check that fetch works |  | ||||||
|         err = lfs_dir_fetch(lfs, &root, (const lfs_block_t[2]){0, 1}); |  | ||||||
|         if (err) { |  | ||||||
|             goto cleanup; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         // force compaction to prevent accidentally mounting any |         // force compaction to prevent accidentally mounting any | ||||||
|         // older version of littlefs that may live on disk |         // older version of littlefs that may live on disk | ||||||
|         root.erased = false; |         root.erased = false; | ||||||
| @@ -3629,6 +3623,12 @@ static int lfs_rawformat(lfs_t *lfs, const struct lfs_config *cfg) { | |||||||
|         if (err) { |         if (err) { | ||||||
|             goto cleanup; |             goto cleanup; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         // sanity check that fetch works | ||||||
|  |         err = lfs_dir_fetch(lfs, &root, (const lfs_block_t[2]){0, 1}); | ||||||
|  |         if (err) { | ||||||
|  |             goto cleanup; | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
| cleanup: | cleanup: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user