mirror of
				https://github.com/eledio-devices/thirdparty-littlefs.git
				synced 2025-10-31 16:14:16 +01:00 
			
		
		
		
	WIP Tweaked inline files to support inline_max == cache_size
This commit is contained in:
		
							
								
								
									
										9
									
								
								lfs.c
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								lfs.c
									
									
									
									
									
								
							| @@ -142,7 +142,7 @@ static inline void lfs_cache_zero(lfs_t *lfs, lfs_cache_t *pcache) { | |||||||
|  |  | ||||||
| static int lfs_cache_flush(lfs_t *lfs, | static int lfs_cache_flush(lfs_t *lfs, | ||||||
|         lfs_cache_t *pcache, lfs_cache_t *rcache, bool validate) { |         lfs_cache_t *pcache, lfs_cache_t *rcache, bool validate) { | ||||||
|     if (pcache->block != 0xffffffff) { |     if (pcache->block != 0xffffffff && pcache->block != 0xfffffffe) { | ||||||
|         LFS_ASSERT(pcache->block < lfs->cfg->block_count); |         LFS_ASSERT(pcache->block < lfs->cfg->block_count); | ||||||
|         lfs_size_t diff = lfs_alignup(pcache->size, lfs->cfg->prog_size); |         lfs_size_t diff = lfs_alignup(pcache->size, lfs->cfg->prog_size); | ||||||
|         int err = lfs->cfg->prog(lfs->cfg, pcache->block, |         int err = lfs->cfg->prog(lfs->cfg, pcache->block, | ||||||
| @@ -2158,7 +2158,10 @@ static int lfs_file_relocate(lfs_t *lfs, lfs_file_t *file) { | |||||||
|         return 0; |         return 0; | ||||||
|  |  | ||||||
| relocate: | relocate: | ||||||
|         continue; |         LFS_DEBUG("Bad block at %"PRIu32, nblock); | ||||||
|  |  | ||||||
|  |         // just clear cache and try a new block | ||||||
|  |         lfs_cache_drop(lfs, &lfs->pcache); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -2397,7 +2400,7 @@ lfs_ssize_t lfs_file_write(lfs_t *lfs, lfs_file_t *file, | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     if ((file->flags & LFS_F_INLINE) && |     if ((file->flags & LFS_F_INLINE) && | ||||||
|             file->pos + nsize >= lfs->inline_max) { |             file->pos + nsize > lfs->inline_max) { | ||||||
|         // inline file doesn't fit anymore |         // inline file doesn't fit anymore | ||||||
|         file->block = 0xfffffffe; |         file->block = 0xfffffffe; | ||||||
|         file->off = file->pos; |         file->off = file->pos; | ||||||
|   | |||||||
| @@ -341,6 +341,10 @@ tests/test.py << TEST | |||||||
|     } |     } | ||||||
|     lfs_file_close(&lfs, &file[0]) => 0; |     lfs_file_close(&lfs, &file[0]) => 0; | ||||||
|  |  | ||||||
|  |     // remount to force reset of lookahead | ||||||
|  |     lfs_unmount(&lfs) => 0; | ||||||
|  |     lfs_mount(&lfs, &cfg) => 0; | ||||||
|  |  | ||||||
|     // open hole |     // open hole | ||||||
|     lfs_remove(&lfs, "bump") => 0; |     lfs_remove(&lfs, "bump") => 0; | ||||||
|  |  | ||||||
| @@ -350,7 +354,7 @@ tests/test.py << TEST | |||||||
|     for (lfs_size_t i = 0; i < cfg.block_size; i += 2) { |     for (lfs_size_t i = 0; i < cfg.block_size; i += 2) { | ||||||
|         memcpy(&buffer[i], "hi", 2); |         memcpy(&buffer[i], "hi", 2); | ||||||
|     } |     } | ||||||
|     lfs_file_write(&lfs, &file[0], buffer, cfg.block_size) => LFS_ERR_NOSPC; |     lfs_file_write(&lfs, &file[0], buffer, 2*cfg.block_size) => LFS_ERR_NOSPC; | ||||||
|     lfs_file_close(&lfs, &file[0]) => 0; |     lfs_file_close(&lfs, &file[0]) => 0; | ||||||
|  |  | ||||||
|     lfs_unmount(&lfs) => 0; |     lfs_unmount(&lfs) => 0; | ||||||
| @@ -388,7 +392,6 @@ tests/test.py << TEST | |||||||
|  |  | ||||||
|     // remount to force reset of lookahead |     // remount to force reset of lookahead | ||||||
|     lfs_unmount(&lfs) => 0; |     lfs_unmount(&lfs) => 0; | ||||||
|  |  | ||||||
|     lfs_mount(&lfs, &cfg) => 0; |     lfs_mount(&lfs, &cfg) => 0; | ||||||
|  |  | ||||||
|     // rewrite one file |     // rewrite one file | ||||||
| @@ -451,7 +454,6 @@ tests/test.py << TEST | |||||||
|  |  | ||||||
|     // remount to force reset of lookahead |     // remount to force reset of lookahead | ||||||
|     lfs_unmount(&lfs) => 0; |     lfs_unmount(&lfs) => 0; | ||||||
|  |  | ||||||
|     lfs_mount(&lfs, &cfg) => 0; |     lfs_mount(&lfs, &cfg) => 0; | ||||||
|  |  | ||||||
|     // rewrite one file with a hole of one block |     // rewrite one file with a hole of one block | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user