diff --git a/components/vfs/Kconfig b/components/vfs/Kconfig index d3954cb3789c..0c7b2ce97277 100644 --- a/components/vfs/Kconfig +++ b/components/vfs/Kconfig @@ -71,6 +71,14 @@ menu "Virtual file system" help Disabling this option can save memory when the support for termios.h is not required. + config VFS_MAX_COUNT + int "Maximum Number of Virtual Filesystems" + default 8 + range 1 20 + depends on VFS_SUPPORT_IO + help + Define maximum number of virtual filesystems that can be registered. + menu "Host File System I/O (Semihosting)" depends on VFS_SUPPORT_IO diff --git a/components/vfs/vfs.c b/components/vfs/vfs.c index 7f681c3c40ff..220fa9a6abc0 100644 --- a/components/vfs/vfs.c +++ b/components/vfs/vfs.c @@ -33,7 +33,16 @@ static const char *TAG = "vfs"; -#define VFS_MAX_COUNT 8 /* max number of VFS entries (registered filesystems) */ +/* Max number of VFS entries (registered filesystems) */ +#ifdef CONFIG_VFS_MAX_COUNT +#define VFS_MAX_COUNT CONFIG_VFS_MAX_COUNT +#else +/* If IO support is disabled, keep this defined to 1 to avoid compiler warnings in this file. + * The s_vfs array and the functions defined here will be removed by the linker, anyway. + */ +#define VFS_MAX_COUNT 1 +#endif + #define LEN_PATH_PREFIX_IGNORED SIZE_MAX /* special length value for VFS which is never recognised by open() */ #define FD_TABLE_ENTRY_UNUSED (fd_table_t) { .permanent = false, .has_pending_close = false, .has_pending_select = false, .vfs_index = -1, .local_fd = -1 }