From 906b3df54b3c40b827c8ad5c43f8b3b16a07ad12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Rohl=C3=ADnek?= Date: Fri, 1 Nov 2024 13:19:23 +0100 Subject: [PATCH] feat(storage/vfs): move nullfs to new API --- components/vfs/include/esp_private/nullfs.h | 2 +- components/vfs/nullfs.c | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/components/vfs/include/esp_private/nullfs.h b/components/vfs/include/esp_private/nullfs.h index 6baec03b0e..070b2b25e0 100644 --- a/components/vfs/include/esp_private/nullfs.h +++ b/components/vfs/include/esp_private/nullfs.h @@ -17,7 +17,7 @@ extern "C" { * * @return VFS structure for /dev/null */ -const esp_vfs_t *esp_vfs_null_get_vfs(void); +const esp_vfs_fs_ops_t *esp_vfs_null_get_vfs(void); #ifdef __cplusplus } diff --git a/components/vfs/nullfs.c b/components/vfs/nullfs.c index 8ac166d2dc..719620cb09 100644 --- a/components/vfs/nullfs.c +++ b/components/vfs/nullfs.c @@ -16,6 +16,7 @@ #include #include #include "esp_vfs.h" +#include "esp_vfs_ops.h" #include "esp_log.h" #include "esp_err.h" #include "esp_private/startup_internal.h" @@ -68,8 +69,13 @@ static int vfs_null_fcntl(int fd, int cmd, int arg); static int vfs_null_ioctl(int fd, int cmd, va_list args); static int vfs_null_fsync(int fd); -static const esp_vfs_t s_vfs_null = { - .flags = ESP_VFS_FLAG_DEFAULT, +#if CONFIG_VFS_SUPPORT_DIR +static const esp_vfs_dir_ops_t s_vfs_null_dir = { + .stat = &vfs_null_stat, +}; +#endif // CONFIG_VFS_SUPPORT_DIR + +static const esp_vfs_fs_ops_t s_vfs_null = { .write = &vfs_null_write, .lseek = &vfs_null_lseek, .read = &vfs_null_read, @@ -78,22 +84,22 @@ static const esp_vfs_t s_vfs_null = { .open = &vfs_null_open, .close = &vfs_null_close, .fstat = &vfs_null_fstat, -#if CONFIG_VFS_SUPPORT_DIR - .stat = &vfs_null_stat, -#endif // CONFIG_VFS_SUPPORT_DIR .fcntl = &vfs_null_fcntl, .ioctl = &vfs_null_ioctl, .fsync = &vfs_null_fsync, +#if CONFIG_VFS_SUPPORT_DIR + .dir = &s_vfs_null_dir, +#endif // CONFIG_VFS_SUPPORT_DIR }; -const esp_vfs_t *esp_vfs_null_get_vfs(void) +const esp_vfs_fs_ops_t *esp_vfs_null_get_vfs(void) { return &s_vfs_null; } esp_err_t esp_vfs_null_register(void) { - return esp_vfs_register("/dev/null", &s_vfs_null, NULL); + return esp_vfs_register_fs("/dev/null", &s_vfs_null, ESP_VFS_FLAG_STATIC, NULL); } static ssize_t vfs_null_write(int fd, const void *data, size_t size)