mirror of
				https://github.com/eledio-devices/thirdparty-littlefs.git
				synced 2025-10-31 08:42:40 +01:00 
			
		
		
		
	Added possibility to open multiple files with LFS_NO_MALLOC enabled.
This commit is contained in:
		
				
					committed by
					
						 Christopher Haster
						Christopher Haster
					
				
			
			
				
	
			
			
			
						parent
						
							f94d233deb
						
					
				
				
					commit
					97711d78c4
				
			
							
								
								
									
										7
									
								
								lfs.c
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								lfs.c
									
									
									
									
									
								
							| @@ -1283,7 +1283,7 @@ static int lfs_ctz_traverse(lfs_t *lfs, | |||||||
|  |  | ||||||
| /// Top level file operations /// | /// Top level file operations /// | ||||||
| int lfs_file_open(lfs_t *lfs, lfs_file_t *file, | int lfs_file_open(lfs_t *lfs, lfs_file_t *file, | ||||||
|         const char *path, int flags) { |         const char *path, int flags, void *file_buffer) { | ||||||
|     // deorphan if we haven't yet, needed at most once after poweron |     // deorphan if we haven't yet, needed at most once after poweron | ||||||
|     if ((flags & 3) != LFS_O_RDONLY && !lfs->deorphaned) { |     if ((flags & 3) != LFS_O_RDONLY && !lfs->deorphaned) { | ||||||
|         int err = lfs_deorphan(lfs); |         int err = lfs_deorphan(lfs); | ||||||
| @@ -1340,7 +1340,10 @@ int lfs_file_open(lfs_t *lfs, lfs_file_t *file, | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     // allocate buffer if needed |     // allocate buffer if needed | ||||||
|     if (lfs->cfg->file_buffer) { |     file->cache.block = 0xffffffff; | ||||||
|  |     if (file_buffer) { | ||||||
|  |         file->cache.buffer = file_buffer; | ||||||
|  |     } else if (lfs->cfg->file_buffer) { | ||||||
|         if (lfs->files) { |         if (lfs->files) { | ||||||
|             // already in use |             // already in use | ||||||
|             return LFS_ERR_NOMEM; |             return LFS_ERR_NOMEM; | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								lfs.h
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								lfs.h
									
									
									
									
									
								
							| @@ -334,7 +334,7 @@ int lfs_stat(lfs_t *lfs, const char *path, struct lfs_info *info); | |||||||
| // | // | ||||||
| // Returns a negative error code on failure. | // Returns a negative error code on failure. | ||||||
| int lfs_file_open(lfs_t *lfs, lfs_file_t *file, | int lfs_file_open(lfs_t *lfs, lfs_file_t *file, | ||||||
|         const char *path, int flags); |         const char *path, int flags, void *file_buffer); | ||||||
|  |  | ||||||
| // Close a file | // Close a file | ||||||
| // | // | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user