From a3ce436841364fe1b3cabc765858df2b62c32f5f Mon Sep 17 00:00:00 2001 From: Hongjin Li Date: Thu, 24 Nov 2022 14:42:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8F=90=E4=BE=9BCONFIG=5FNFILE=5FDESCR?= =?UTF-8?q?IPTORS=E5=AE=8F=E6=A0=87=E8=AF=86=E6=9C=80=E5=A4=A7=E5=8F=AF?= =?UTF-8?q?=E6=89=93=E5=BC=80fd=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 提供CONFIG_NFILE_DESCRIPTORS宏,标识最大可打开fd数量。 提供FAT_MAX_OPEN_FILES宏,标识FAT文件系统中最大可打开fd数量。 如果只有FAT文件系统,那么CONFIG_NFILE_DESCRIPTORS等于FAT_MAX_OPEN_FILES。 如果有多个文件系统,比如fat+little+yaffs,那么CONFIG_NFILE_DESCRIPTORS应该定义为多个文件系统可打开fd数量之和。 BREAKING CHANGE: 对外提供的CONFIG_NFILE_DESCRIPTORS宏,用来标识最大可打开fd数量。 开发者可以在target_config.h中自定义CONFIG_NFILE_DESCRIPTORS和FAT_MAX_OPEN_FILES宏。 Close #I62WDU Signed-off-by: Hongjin Li --- components/fs/vfs/vfs_config.h | 10 +++------- components/fs/vfs/vfs_fs.c | 4 ---- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/components/fs/vfs/vfs_config.h b/components/fs/vfs/vfs_config.h index 93cc10a3..74640798 100644 --- a/components/fs/vfs/vfs_config.h +++ b/components/fs/vfs/vfs_config.h @@ -49,19 +49,15 @@ #ifdef LOSCFG_FS_FAT #include "fatfs_conf.h" -#define __FAT_NFILE FAT_MAX_OPEN_FILES -#else -#define __FAT_NFILE 0 #endif #ifdef LOSCFG_FS_LITTLEFS #include "lfs_conf.h" -#define __LFS_NFILE LOSCFG_LFS_MAX_OPEN_FILES -#else -#define __LFS_NFILE 0 #endif -#define CONFIG_NFILE_DESCRIPTORS (__FAT_NFILE + __LFS_NFILE) +#ifndef CONFIG_NFILE_DESCRIPTORS +#define CONFIG_NFILE_DESCRIPTORS 256 +#endif #define NR_OPEN_DEFAULT CONFIG_NFILE_DESCRIPTORS diff --git a/components/fs/vfs/vfs_fs.c b/components/fs/vfs/vfs_fs.c index daf1ee8e..0bec9575 100644 --- a/components/fs/vfs/vfs_fs.c +++ b/components/fs/vfs/vfs_fs.c @@ -57,10 +57,6 @@ #define CONFIG_NSOCKET_DESCRIPTORS 0 #endif -#ifndef CONFIG_NFILE_DESCRIPTORS -#define CONFIG_NFILE_DESCRIPTORS 256 -#endif - #ifdef LOSCFG_RANDOM_DEV #include "hks_client.h" #define RANDOM_DEV_FD CONFIG_NFILE_DESCRIPTORS + CONFIG_NSOCKET_DESCRIPTORS