Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to config the maximum number of VFS entries. (IDFGH-9641) #10987

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions components/vfs/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion components/vfs/vfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@

static const char *TAG = "vfs";

#define VFS_MAX_COUNT 8 /* max number of VFS entries (registered filesystems) */
Copy link
Member

@igrr igrr Apr 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One note, here I had to re-introduce VFS_MAX_COUNT macro so it's still defined even if CONFIG_VFS_SUPPORT_IO is not set. Otherwise the build would fail when CONFIG_VFS_SUPPORT_IO is disabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your time and sorry for wasting it on this not fully functional pull request!

I'm now instead following a pattern I find all over the place in the ESP-IDF code base.

#ifdef CONFIG_VFS_MAX_COUNT
#define VFS_MAX_COUNT CONFIG_VFS_MAX_COUNT /* max number of VFS entries (registered filesystems) */
#else
#define VFS_MAX_COUNT 8 /* max number of VFS entries (registered filesystems) */
#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 }

Expand Down