mirror of
				https://github.com/eledio-devices/thirdparty-littlefs.git
				synced 2025-10-31 00:32:38 +01:00 
			
		
		
		
	Fix lfs_file_seek doesn't update cache properties correctly in readonly mode. Invalidate cache to fix it.
This commit is contained in:
		
				
					committed by
					
						 Christopher Haster
						Christopher Haster
					
				
			
			
				
	
			
			
			
						parent
						
							ead50807f1
						
					
				
				
					commit
					e955b9f65d
				
			
							
								
								
									
										12
									
								
								lfs.c
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								lfs.c
									
									
									
									
									
								
							| @@ -2730,14 +2730,18 @@ static int lfs_file_outline(lfs_t *lfs, lfs_file_t *file) { | ||||
| } | ||||
| #endif | ||||
|  | ||||
| #ifndef LFS_READONLY | ||||
| static int lfs_file_flush(lfs_t *lfs, lfs_file_t *file) { | ||||
| static void lfs_file_invalidate_reading_flag(lfs_t *lfs, lfs_file_t *file) { | ||||
|     if (file->flags & LFS_F_READING) { | ||||
|         if (!(file->flags & LFS_F_INLINE)) { | ||||
|             lfs_cache_drop(lfs, &file->cache); | ||||
|         } | ||||
|         file->flags &= ~LFS_F_READING; | ||||
|     } | ||||
| } | ||||
|  | ||||
| #ifndef LFS_READONLY | ||||
| static int lfs_file_flush(lfs_t *lfs, lfs_file_t *file) { | ||||
|     lfs_file_invalidate_reading_flag(lfs, file); | ||||
|  | ||||
|     if (file->flags & LFS_F_WRITING) { | ||||
|         lfs_off_t pos = file->pos; | ||||
| @@ -3087,6 +3091,10 @@ static lfs_soff_t lfs_file_rawseek(lfs_t *lfs, lfs_file_t *file, | ||||
|     if (err) { | ||||
|         return err; | ||||
|     } | ||||
| #else | ||||
|     // Seek doesn't update cache parameters properly. | ||||
|     // It has to be invalidated otherwise next read will return incorrect values. | ||||
|     lfs_file_invalidate_reading_flag(lfs,file); | ||||
| #endif | ||||
|  | ||||
|     // update pos | ||||
|   | ||||
		Reference in New Issue
	
	Block a user