diff --git a/components/fs/littlefs/Kconfig b/components/fs/littlefs/Kconfig index c08c7915..cd29283e 100644 --- a/components/fs/littlefs/Kconfig +++ b/components/fs/littlefs/Kconfig @@ -42,4 +42,9 @@ config LFS_MAX_MOUNT_SIZE help This is a global maximum number of mount points. +config LFS_MAX_OPEN_FILES + int "Maximum number of open files" + default 100 + help + This is a global maximum number of open files. endif # FS_LITTLEFS diff --git a/components/fs/littlefs/lfs_api.c b/components/fs/littlefs/lfs_api.c index 30a1610a..bc11c6d2 100644 --- a/components/fs/littlefs/lfs_api.c +++ b/components/fs/littlefs/lfs_api.c @@ -38,7 +38,7 @@ lfs_t g_lfs; FileDirInfo g_lfsDir[LFS_MAX_OPEN_DIRS] = {0}; struct FileOpInfo g_fsOp[LOSCFG_LFS_MAX_MOUNT_SIZE] = {0}; -static LittleFsHandleStruct g_handle[LITTLE_FS_MAX_OPEN_FILES] = {0}; +static LittleFsHandleStruct g_handle[LOSCFG_LFS_MAX_OPEN_FILES] = {0}; struct dirent g_nameValue; static pthread_mutex_t g_FslocalMutex = PTHREAD_MUTEX_INITIALIZER; static const char *g_littlefsMntName[LOSCFG_LFS_MAX_MOUNT_SIZE] = {"/a"}; @@ -46,7 +46,7 @@ static const char *g_littlefsMntName[LOSCFG_LFS_MAX_MOUNT_SIZE] = {"/a"}; LittleFsHandleStruct *LfsAllocFd(const char *fileName, int *fd) { pthread_mutex_lock(&g_FslocalMutex); - for (int i = 0; i < LITTLE_FS_MAX_OPEN_FILES; i++) { + for (int i = 0; i < LOSCFG_LFS_MAX_OPEN_FILES; i++) { if (g_handle[i].useFlag == 0) { *fd = i; g_handle[i].useFlag = 1; @@ -78,7 +78,7 @@ static void LfsFreeFd(int fd) BOOL CheckFileIsOpen(const char *fileName) { pthread_mutex_lock(&g_FslocalMutex); - for (int i = 0; i < LITTLE_FS_MAX_OPEN_FILES; i++) { + for (int i = 0; i < LOSCFG_LFS_MAX_OPEN_FILES; i++) { if (g_handle[i].useFlag == 1) { if (strcmp(g_handle[i].pathName, fileName) == 0) { pthread_mutex_unlock(&g_FslocalMutex); @@ -92,7 +92,7 @@ BOOL CheckFileIsOpen(const char *fileName) static BOOL LfsFdIsValid(int fd) { - if (fd >= LITTLE_FS_MAX_OPEN_FILES || fd < 0) { + if (fd >= LOSCFG_LFS_MAX_OPEN_FILES || fd < 0) { return FALSE; } if (g_handle[fd].lfsHandle == NULL) { diff --git a/components/fs/littlefs/lfs_conf.h b/components/fs/littlefs/lfs_conf.h index f0f785bb..4aa8174c 100644 --- a/components/fs/littlefs/lfs_conf.h +++ b/components/fs/littlefs/lfs_conf.h @@ -31,7 +31,6 @@ #ifndef _LFS_CONF_H #define _LFS_CONF_H -#define LITTLE_FS_MAX_OPEN_FILES 100 #define LITTLE_FS_STANDARD_NAME_LENGTH 50 #define LITTLE_FS_MAX_NAME_LEN 255 diff --git a/components/fs/vfs/vfs_config.h b/components/fs/vfs/vfs_config.h index f0ad857d..a3538a34 100644 --- a/components/fs/vfs/vfs_config.h +++ b/components/fs/vfs/vfs_config.h @@ -106,7 +106,7 @@ #ifdef LOSCFG_FS_LITTLEFS #include "lfs_conf.h" -#define __LFS_NFILE LITTLE_FS_MAX_OPEN_FILES +#define __LFS_NFILE LOSCFG_LFS_MAX_OPEN_FILES #else #define __LFS_NFILE 0 #endif