mirror of
				https://github.com/eledio-devices/thirdparty-littlefs.git
				synced 2025-10-31 08:42:40 +01:00 
			
		
		
		
	A number of small lfs_util.h QOL changes
- Changed the name of the LFS_CONFIG macro to LFS_UTIL to avoid confusion with the lfs_config struct. This also hints that LFS_UTIL is related to lfs_util.h. LFS_UTIL allows the user to override lfs_util.h so they can provide their own system-level dependencies such as malloc, tracing, builtins, stdint definitions, string.h, and others. - Removed stdlib includes from lfs.h, these should all go through lfs_util.h to let users override these definitions if stdlib is unavailable on their system. - Moved error code definitions to lfs_util.h. This lets users override the error codes to replace them with their own error codes and avoid a translation layer in some situations. Note the error codes must still be in the range of a negative int. - Used proper stdint definitions in lfs_scmp.
This commit is contained in:
		
							
								
								
									
										28
									
								
								lfs.h
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								lfs.h
									
									
									
									
									
								
							| @@ -7,12 +7,10 @@ | ||||
| #ifndef LFS_H | ||||
| #define LFS_H | ||||
|  | ||||
| #include <stdint.h> | ||||
| #include <stdbool.h> | ||||
| #include "lfs_util.h" | ||||
|  | ||||
| #ifdef __cplusplus | ||||
| extern "C" | ||||
| { | ||||
| extern "C" { | ||||
| #endif | ||||
|  | ||||
|  | ||||
| @@ -66,26 +64,6 @@ typedef uint32_t lfs_block_t; | ||||
| #define LFS_ATTR_MAX 1022 | ||||
| #endif | ||||
|  | ||||
| // Possible error codes, these are negative to allow | ||||
| // valid positive return values | ||||
| enum lfs_error { | ||||
|     LFS_ERR_OK          = 0,    // No error | ||||
|     LFS_ERR_IO          = -5,   // Error during device operation | ||||
|     LFS_ERR_CORRUPT     = -84,  // Corrupted | ||||
|     LFS_ERR_NOENT       = -2,   // No directory entry | ||||
|     LFS_ERR_EXIST       = -17,  // Entry already exists | ||||
|     LFS_ERR_NOTDIR      = -20,  // Entry is not a dir | ||||
|     LFS_ERR_ISDIR       = -21,  // Entry is a dir | ||||
|     LFS_ERR_NOTEMPTY    = -39,  // Dir is not empty | ||||
|     LFS_ERR_BADF        = -9,   // Bad file number | ||||
|     LFS_ERR_FBIG        = -27,  // File too large | ||||
|     LFS_ERR_INVAL       = -22,  // Invalid parameter | ||||
|     LFS_ERR_NOSPC       = -28,  // No space left on device | ||||
|     LFS_ERR_NOMEM       = -12,  // No more memory available | ||||
|     LFS_ERR_NOATTR      = -61,  // No data/attr available | ||||
|     LFS_ERR_NAMETOOLONG = -36,  // File name too long | ||||
| }; | ||||
|  | ||||
| // File types | ||||
| enum lfs_type { | ||||
|     // file types | ||||
| @@ -649,7 +627,7 @@ int lfs_migrate(lfs_t *lfs, const struct lfs_config *cfg); | ||||
|  | ||||
|  | ||||
| #ifdef __cplusplus | ||||
| } /* extern "C" */ | ||||
| } | ||||
| #endif | ||||
|  | ||||
| #endif | ||||
|   | ||||
		Reference in New Issue
	
	Block a user