Merge branch 'feat/unify_vfs_api_v6.0' into 'release/v6.0'

feat(storage/vfs): Unify VFS API by removing context-less APIs (v6.0)

See merge request espressif/esp-idf!46747
This commit is contained in:
Martin Vychodil
2026-03-24 22:49:06 +08:00
19 changed files with 311 additions and 241 deletions
+5
View File
@@ -19,6 +19,10 @@ FS Registration
To register an FS driver, an application needs to define an instance of the :cpp:type:`esp_vfs_fs_ops_t` structure and populate it with function pointers to FS APIs:
.. warning::
The API version without a context pointer is deprecated, and will be removed in the future. See :ref:`context_api` for details.
.. highlight:: c
::
@@ -65,6 +69,7 @@ The recommended approach for registering filesystem is to use statically allocat
ESP_ERROR_CHECK(esp_vfs_register_fs("/data", &myfs, ESP_VFS_FLAG_DEFAULT, NULL));
}
.. _context_api:
Context Aware Filesystem
^^^^^^^^^^^^^^^^^^^^^^^^
@@ -19,6 +19,7 @@ VFS
- ``esp_vfs_register_fd_range`` is now considered private and its signature was changed to match the new VFS API style. Projects that still rely on this internal helper must include ``esp_private/socket.h`` and should be aware that the API may change without notice.
- Legacy VFS APIs (such as ``esp_vfs_register``) that operate on ``esp_vfs_t`` instead of ``esp_vfs_fs_ops_t`` are deprecated and will be removed in the next major release. Switch to the new ``esp_vfs_fs_ops_t``-based APIs.
- TERMIOS support is now disabled by default. Re-enable :ref:`CONFIG_VFS_SUPPORT_TERMIOS` in menuconfig if your application calls POSIX ``termios`` APIs, such as ``tcsetattr``/``tcgetattr`` for UART configuration.
- Context-less VFS function pointers are deprecated. Switch to the context-aware ``*_p`` callbacks, register the VFS with ``ESP_VFS_FLAG_CONTEXT_PTR``, and pass ``NULL`` as the context pointer if the driver does not need per-instance state. This change simplifies the API surface and reduces runtime overhead in the VFS call path.
``esp_vfs_console``
+5
View File
@@ -19,6 +19,10 @@ VFS 组件支持 C 库函数(如 fopen 和 fprintf 等)与文件系统 (FS)
如需注册 FS 驱动程序,应用程序首先要定义一个 :cpp:type:`esp_vfs_fs_ops_t` 结构体实例,并用指向 FS API 的函数指针填充它。
.. warning::
不带上下文指针的 API 版本已弃用,未来将被移除,请参见 :ref:`context_api`
.. highlight:: c
::
@@ -65,6 +69,7 @@ VFS 组件支持 C 库函数(如 fopen 和 fprintf 等)与文件系统 (FS)
ESP_ERROR_CHECK(esp_vfs_register_fs("/data", &myfs, ESP_VFS_FLAG_DEFAULT, NULL));
}
.. _context_api:
上下文感知文件系统
^^^^^^^^^^^^^^^^^^
@@ -19,6 +19,7 @@ VFS
- ``esp_vfs_register_fd_range`` 现被视为私有接口,其函数签名已调整为匹配新的 VFS API 风格。仍依赖此内部辅助函数的项目需包含 ``esp_private/socket.h`` 头文件,并请注意该 API 可能在不另行通知的情况下发生变更。
- 基于 ``esp_vfs_t`` 而非 ``esp_vfs_fs_ops_t`` 的传统 VFS API(如 ``esp_vfs_register``)已弃用,并将在下一个主版本中移除。请迁移至基于 ``esp_vfs_fs_ops_t`` 的新 API。
- TERMIOS 支持现已默认禁用。若应用程序需调用 POSIX ``termios`` API(例如用于 UART 配置的 ``tcsetattr``/``tcgetattr`` 接口),请在 menuconfig 中重新启用 :ref:`CONFIG_VFS_SUPPORT_TERMIOS` 选项。
- 不带上下文的 VFS 函数指针已弃用。请切换到带上下文感知的 ``*_p`` 系列回调函数,并使用 ``ESP_VFS_FLAG_CONTEXT_PTR`` 标志注册 VFS。如果驱动不需要每个实例各自的状态,则将上下文指针传入 ``NULL`` 即可。此项变更简化了 API 接口,并减少了 VFS 调用路径中的运行时开销。
``esp_vfs_console``
--------------------