From 3e41a5de6fa86d298e215e9f6781b5cfa05ec73d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Rohl=C3=ADnek?= Date: Thu, 11 Dec 2025 08:31:32 +0100 Subject: [PATCH] feat(storage/vfs): Deprecate legacy API --- components/vfs/include/esp_vfs.h | 7 +++---- components/vfs/vfs.c | 22 +++++++++++----------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/components/vfs/include/esp_vfs.h b/components/vfs/include/esp_vfs.h index d38b091e62d..941c4a4fe69 100644 --- a/components/vfs/include/esp_vfs.h +++ b/components/vfs/include/esp_vfs.h @@ -48,7 +48,7 @@ extern "C" { #define ESP_VFS_PATH_MAX 15 /** - * Default value of flags member in esp_vfs_t structure. + * Default value of flags member in esp_vfs_fs_ops_t structure. */ #define ESP_VFS_FLAG_DEFAULT (1 << 0) @@ -70,6 +70,7 @@ extern "C" { /** * @brief VFS definition structure + * @note Prefer using esp_vfs_fs_ops_t with esp_vfs_register_fs*() instead. * * This structure should be filled with pointers to corresponding * FS driver functions. @@ -250,8 +251,6 @@ typedef struct #endif // CONFIG_VFS_SUPPORT_SELECT || defined __DOXYGEN__ } esp_vfs_t; - - /** * Register a virtual filesystem for given path prefix. * @@ -293,7 +292,7 @@ esp_err_t esp_vfs_register(const char* base_path, const esp_vfs_t* vfs, void* ct * registered, ESP_ERR_INVALID_ARG if the file descriptor boundaries * are incorrect. */ -esp_err_t esp_vfs_register_with_id(const esp_vfs_t *vfs, void *ctx, esp_vfs_id_t *vfs_id); +esp_err_t esp_vfs_register_with_id(const esp_vfs_t *vfs, void *ctx, esp_vfs_id_t *vfs_id) __attribute__((deprecated("Use esp_vfs_register_fs_with_id() instead"))); /** * Unregister a virtual filesystem for given path prefix diff --git a/components/vfs/vfs.c b/components/vfs/vfs.c index 534839e3252..b1e6bf202b8 100644 --- a/components/vfs/vfs.c +++ b/components/vfs/vfs.c @@ -522,6 +522,16 @@ esp_err_t esp_vfs_register(const char* base_path, const esp_vfs_t* vfs, void* ct return esp_vfs_register_common(base_path, strlen(base_path), vfs, ctx, NULL); } +esp_err_t esp_vfs_register_with_id(const esp_vfs_t *vfs, void *ctx, esp_vfs_id_t *vfs_id) +{ + if (vfs_id == NULL) { + return ESP_ERR_INVALID_ARG; + } + + *vfs_id = -1; + return esp_vfs_register_common("", LEN_PATH_PREFIX_IGNORED, vfs, ctx, vfs_id); +} + esp_err_t esp_vfs_register_fd_range(const esp_vfs_fs_ops_t *vfs, int flags, void *ctx, int min_fd, int max_fd) { if (min_fd < 0 || max_fd < 0 || min_fd > MAX_FDS || max_fd > MAX_FDS || min_fd > max_fd) { @@ -530,7 +540,7 @@ esp_err_t esp_vfs_register_fd_range(const esp_vfs_fs_ops_t *vfs, int flags, void } int index = 0; - esp_err_t ret = esp_vfs_register_common("", LEN_PATH_PREFIX_IGNORED, vfs, ctx, &index); + esp_err_t ret = esp_vfs_register_fs_common(NULL, vfs, flags, ctx, &index); if (ret == ESP_OK) { _lock_acquire(&s_fd_table_lock); @@ -569,16 +579,6 @@ esp_err_t esp_vfs_register_fs_with_id(const esp_vfs_fs_ops_t *vfs, int flags, vo return esp_vfs_register_fs_common(NULL, vfs, flags, ctx, vfs_id); } -esp_err_t esp_vfs_register_with_id(const esp_vfs_t *vfs, void *ctx, esp_vfs_id_t *vfs_id) -{ - if (vfs_id == NULL) { - return ESP_ERR_INVALID_ARG; - } - - *vfs_id = -1; - return esp_vfs_register_common("", LEN_PATH_PREFIX_IGNORED, vfs, ctx, vfs_id); -} - esp_err_t esp_vfs_unregister_with_id(esp_vfs_id_t vfs_id) { if (vfs_id < 0 || vfs_id >= VFS_MAX_COUNT || s_vfs[vfs_id] == NULL) {