From 28a49af314ee19b9b735ab1d5edf3a36be3ddcec Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Mon, 27 Dec 2021 08:53:27 +0000 Subject: [PATCH] git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@15264 27425a3e-05d8-49a3-a47f-9c15f0e5edd8 --- os/vfs/include/vfsdrivers.h | 69 +++++++++++++++++++++++++++++++++++++ os/vfs/src/vfs.c | 8 ++--- 2 files changed, 73 insertions(+), 4 deletions(-) diff --git a/os/vfs/include/vfsdrivers.h b/os/vfs/include/vfsdrivers.h index a178e6e2c..34ec48acc 100644 --- a/os/vfs/include/vfsdrivers.h +++ b/os/vfs/include/vfsdrivers.h @@ -121,6 +121,75 @@ extern "C" { /* Module inline functions. */ /*===========================================================================*/ +/** + * @brief Changes the current VFS directory. + * + * @param[in] drvp Pointer to the @p vfs_driver_c object. + * @param[in] path Path of the new current directory. + * @return The operation result. + * + * @api + */ +static inline msg_t vfsDrvChangeCurrentDirectory(vfs_driver_c *drvp, + const char *path) { + + return drvp->vmt->set_cwd(drvp, path); +} + +/** + * @brief Returns the current VFS directory. + * + * @param[in] drvp Pointer to the @p vfs_driver_c object. + * @param[out] buf Buffer for the path string. + * @param[in] size Size of the buffer. + * @return The operation result. + * + * @api + */ +static inline msg_t vfsDrvGetCurrentDirectory(vfs_driver_c *drvp, + char *buf, size_t size) { + + return drvp->vmt->get_cwd(drvp, buf, size); +} + +/** + * @brief Opens a VFS directory. + * + * @param[in] drvp Pointer to the @p vfs_driver_c object. + * @param[in] path Absolute path of the directory to be opened. + * @param[out] vdnpp Pointer to the pointer to the instantiated. + * @p vfs_directory_node_c object + * @return The operation result. + * + * @api + */ +static inline msg_t vfsDrvOpenDirectory(vfs_driver_c *drvp, + const char *path, + vfs_directory_node_c **vdnpp) { + + return drvp->vmt->open_dir(drvp, path, vdnpp); +} + +/** + * @brief Opens a VFS file. + * + * @param[in] drvp Pointer to the @p vfs_driver_c object. + * @param[in] path Path of the file to be opened. + * @param[in] mode File open mode. + * @param[out] vdnpp Pointer to the pointer to the instantiated + * @p vfs_file_node_c object. + * @return The operation result. + * + * @api + */ +static inline msg_t vfsDrvOpenFile(vfs_driver_c *drvp, + const char *path, + unsigned mode, + vfs_file_node_c **vfnpp) { + + return drvp->vmt->open_file(drvp, path, mode, vfnpp); +} + #endif /* VFSDRIVERS_H */ /** @} */ diff --git a/os/vfs/src/vfs.c b/os/vfs/src/vfs.c index 0aee3a405..b1b11d5e3 100644 --- a/os/vfs/src/vfs.c +++ b/os/vfs/src/vfs.c @@ -84,7 +84,7 @@ void vfsInit(void) { */ msg_t vfsChangeCurrentDirectory(const char *path) { - return vfs_root->vmt->set_cwd(vfs_root, path); + return vfsDrvChangeCurrentDirectory(vfs_root, path); } /** @@ -98,7 +98,7 @@ msg_t vfsChangeCurrentDirectory(const char *path) { */ msg_t vfsGetCurrentDirectory(char *buf, size_t size) { - return vfs_root->vmt->get_cwd(vfs_root, buf, size); + return vfsDrvGetCurrentDirectory(vfs_root, buf, size); } /** @@ -114,7 +114,7 @@ msg_t vfsGetCurrentDirectory(char *buf, size_t size) { msg_t vfsOpenDirectory(const char *path, vfs_directory_node_c **vdnpp) { - return vfs_root->vmt->open_dir(vfs_root, path, vdnpp); + return vfsDrvOpenDirectory(vfs_root, path, vdnpp); } /** @@ -179,7 +179,7 @@ msg_t vfsOpenFile(const char *path, unsigned mode, vfs_file_node_c **vfnpp) { - return vfs_root->vmt->open_file(vfs_root, path, mode, vfnpp); + return vfsDrvOpenFile(vfs_root, path, mode, vfnpp); } /**