mirror of
				https://github.com/eledio-devices/thirdparty-littlefs.git
				synced 2025-10-31 00:32:38 +01:00 
			
		
		
		
	Fixed issue with handling block device errors in lfs_file_sync
lfs_file_sync was not correctly setting the LFS_F_ERRED flag. Fortunately this is a relatively easy fix. LFS_F_ERRED prevents further issues from occuring when cleaning up resources with lfs_file_close. found by TheLoneWolfling
This commit is contained in:
		
							
								
								
									
										3
									
								
								lfs.c
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								lfs.c
									
									
									
									
									
								
							| @@ -2578,6 +2578,7 @@ int lfs_file_sync(lfs_t *lfs, lfs_file_t *file) { | ||||
|     while (true) { | ||||
|         int err = lfs_file_flush(lfs, file); | ||||
|         if (err) { | ||||
|             file->flags |= LFS_F_ERRED; | ||||
|             return err; | ||||
|         } | ||||
|  | ||||
| @@ -2613,6 +2614,7 @@ int lfs_file_sync(lfs_t *lfs, lfs_file_t *file) { | ||||
|                 if (err == LFS_ERR_NOSPC && (file->flags & LFS_F_INLINE)) { | ||||
|                     goto relocate; | ||||
|                 } | ||||
|                 file->flags |= LFS_F_ERRED; | ||||
|                 return err; | ||||
|             } | ||||
|  | ||||
| @@ -2626,6 +2628,7 @@ relocate: | ||||
|         file->off = file->pos; | ||||
|         err = lfs_file_relocate(lfs, file); | ||||
|         if (err) { | ||||
|             file->flags |= LFS_F_ERRED; | ||||
|             return err; | ||||
|         } | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user