From ecf1ede7103c58e016d28fc9aa54271b294666fa Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Sat, 22 Jan 2022 15:31:26 +0000 Subject: [PATCH] Implementation stubs for the new VFS API. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@15400 27425a3e-05d8-49a3-a47f-9c15f0e5edd8 --- os/vfs/drivers/fatfs/drvfatfs.c | 6 ++++- os/vfs/drivers/overlay/drvoverlay.c | 20 +++++++++------ os/vfs/drivers/sfs/drvsfs.c | 20 +++++++++------ os/vfs/drivers/streams/drvstreams.c | 6 ++++- os/vfs/drivers/template/drvtemplate.c | 20 +++++++++------ os/vfs/include/vfsdrivers.h | 7 ++++++ os/vfs/src/vfsdrivers.c | 36 +++++++++++++++++++++++++++ 7 files changed, 89 insertions(+), 26 deletions(-) diff --git a/os/vfs/drivers/fatfs/drvfatfs.c b/os/vfs/drivers/fatfs/drvfatfs.c index 9f28b4b6a..e68a07aed 100644 --- a/os/vfs/drivers/fatfs/drvfatfs.c +++ b/os/vfs/drivers/fatfs/drvfatfs.c @@ -124,7 +124,11 @@ static const struct vfs_fatfs_driver_vmt driver_vmt = { .set_cwd = drv_set_cwd, .get_cwd = drv_get_cwd, .open_dir = drv_open_dir, - .open_file = drv_open_file + .open_file = drv_open_file, + .unlink = drv_unlink_unimpl, + .rename = drv_rename_unimpl, + .mkdir = drv_mkdir_unimpl, + .rmdir = drv_rmdir_unimpl }; static void *node_dir_addref(void *instance); diff --git a/os/vfs/drivers/overlay/drvoverlay.c b/os/vfs/drivers/overlay/drvoverlay.c index 96b4a4ee7..c855b2810 100644 --- a/os/vfs/drivers/overlay/drvoverlay.c +++ b/os/vfs/drivers/overlay/drvoverlay.c @@ -56,10 +56,14 @@ static msg_t drv_open_file(void *instance, vfs_file_node_c **vfnpp); static const struct vfs_overlay_driver_vmt driver_vmt = { - .set_cwd = drv_set_cwd, - .get_cwd = drv_get_cwd, - .open_dir = drv_open_dir, - .open_file = drv_open_file + .set_cwd = drv_set_cwd, + .get_cwd = drv_get_cwd, + .open_dir = drv_open_dir, + .open_file = drv_open_file, + .unlink = drv_unlink_unimpl, + .rename = drv_rename_unimpl, + .mkdir = drv_mkdir_unimpl, + .rmdir = drv_rmdir_unimpl }; static void *node_dir_addref(void *instance); @@ -68,10 +72,10 @@ static msg_t node_dir_first(void *instance, vfs_direntry_info_t *dip); static msg_t node_dir_next(void *instance, vfs_direntry_info_t *dip); static const struct vfs_overlay_dir_node_vmt dir_node_vmt = { - .addref = node_dir_addref, - .release = node_dir_release, - .dir_first = node_dir_first, - .dir_next = node_dir_next + .addref = node_dir_addref, + .release = node_dir_release, + .dir_first = node_dir_first, + .dir_next = node_dir_next }; /** diff --git a/os/vfs/drivers/sfs/drvsfs.c b/os/vfs/drivers/sfs/drvsfs.c index ee2207fdc..75a31640f 100644 --- a/os/vfs/drivers/sfs/drvsfs.c +++ b/os/vfs/drivers/sfs/drvsfs.c @@ -56,10 +56,14 @@ static msg_t drv_open_file(void *instance, vfs_file_node_c **vfnpp); static const struct vfs_sfs_driver_vmt driver_vmt = { - .set_cwd = drv_set_cwd, - .get_cwd = drv_get_cwd, - .open_dir = drv_open_dir, - .open_file = drv_open_file + .set_cwd = drv_set_cwd, + .get_cwd = drv_get_cwd, + .open_dir = drv_open_dir, + .open_file = drv_open_file, + .unlink = drv_unlink_unimpl, + .rename = drv_rename_unimpl, + .mkdir = drv_mkdir_unimpl, + .rmdir = drv_rmdir_unimpl }; static void *node_dir_addref(void *instance); @@ -68,10 +72,10 @@ static msg_t node_dir_first(void *instance, vfs_direntry_info_t *dip); static msg_t node_dir_next(void *instance, vfs_direntry_info_t *dip); static const struct vfs_sfs_dir_node_vmt dir_node_vmt = { - .addref = node_dir_addref, - .release = node_dir_release, - .dir_first = node_dir_first, - .dir_next = node_dir_next + .addref = node_dir_addref, + .release = node_dir_release, + .dir_first = node_dir_first, + .dir_next = node_dir_next }; static void *node_file_addref(void *instance); diff --git a/os/vfs/drivers/streams/drvstreams.c b/os/vfs/drivers/streams/drvstreams.c index efb9a23d1..5e567f1ea 100644 --- a/os/vfs/drivers/streams/drvstreams.c +++ b/os/vfs/drivers/streams/drvstreams.c @@ -59,7 +59,11 @@ static const struct vfs_streams_driver_vmt driver_vmt = { .set_cwd = drv_set_cwd, .get_cwd = drv_get_cwd, .open_dir = drv_open_dir, - .open_file = drv_open_file + .open_file = drv_open_file, + .unlink = drv_unlink_unimpl, + .rename = drv_rename_unimpl, + .mkdir = drv_mkdir_unimpl, + .rmdir = drv_rmdir_unimpl }; static void *node_dir_addref(void *instance); diff --git a/os/vfs/drivers/template/drvtemplate.c b/os/vfs/drivers/template/drvtemplate.c index b65eaa0b4..4b4cc23d2 100644 --- a/os/vfs/drivers/template/drvtemplate.c +++ b/os/vfs/drivers/template/drvtemplate.c @@ -56,10 +56,14 @@ static msg_t drv_open_file(void *instance, vfs_file_node_c **vfnpp); static const struct vfs_template_driver_vmt driver_vmt = { - .set_cwd = drv_set_cwd, - .get_cwd = drv_get_cwd, - .open_dir = drv_open_dir, - .open_file = drv_open_file + .set_cwd = drv_set_cwd, + .get_cwd = drv_get_cwd, + .open_dir = drv_open_dir, + .open_file = drv_open_file, + .unlink = drv_unlink_unimpl, + .rename = drv_rename_unimpl, + .mkdir = drv_mkdir_unimpl, + .rmdir = drv_rmdir_unimpl }; static void *node_dir_addref(void *instance); @@ -68,10 +72,10 @@ static msg_t node_dir_first(void *instance, vfs_direntry_info_t *dip); static msg_t node_dir_next(void *instance, vfs_direntry_info_t *dip); static const struct vfs_template_dir_node_vmt dir_node_vmt = { - .addref = node_dir_addref, - .release = node_dir_release, - .dir_first = node_dir_first, - .dir_next = node_dir_next + .addref = node_dir_addref, + .release = node_dir_release, + .dir_first = node_dir_first, + .dir_next = node_dir_next }; static void *node_file_addref(void *instance); diff --git a/os/vfs/include/vfsdrivers.h b/os/vfs/include/vfsdrivers.h index 784ef4958..792ced89d 100644 --- a/os/vfs/include/vfsdrivers.h +++ b/os/vfs/include/vfsdrivers.h @@ -120,6 +120,13 @@ extern "C" { const char *path, int flags, vfs_node_c **vnpp); + msg_t drv_unlink_unimpl(void *instance, const char *path); + msg_t drv_rename_unimpl(void *instance, + const char *oldpath, + const char *newpath); + msg_t drv_mkdir_unimpl(void *instance, + const char *path); + msg_t drv_rmdir_unimpl(void *instance, const char *path); #ifdef __cplusplus } #endif diff --git a/os/vfs/src/vfsdrivers.c b/os/vfs/src/vfsdrivers.c index 6724c42b9..5dc1b9296 100644 --- a/os/vfs/src/vfsdrivers.c +++ b/os/vfs/src/vfsdrivers.c @@ -83,4 +83,40 @@ msg_t vfsDrvOpen(vfs_driver_c *drvp, return ret; } +msg_t drv_unlink_unimpl(void *instance, const char *path) { + + (void)instance; + (void)path; + + return CH_RET_ENOSYS; +} + +msg_t drv_rename_unimpl(void *instance, + const char *oldpath, + const char *newpath) { + + (void)instance; + (void)oldpath; + (void)newpath; + + return CH_RET_ENOSYS; +} + +msg_t drv_mkdir_unimpl(void *instance, + const char *path) { + + (void)instance; + (void)path; + + return CH_RET_ENOSYS; +} + +msg_t drv_rmdir_unimpl(void *instance, const char *path) { + + (void)instance; + (void)path; + + return CH_RET_ENOSYS; +} + /** @} */