|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Path-namespace operations over the ra8_io VFS named-mount table. More...
#include <stdint.h>#include "ra8_attributes.h"#include "ra8_check.h"#include "ra8_err.h"#include "ra8_fs.h"#include "ra8_io_fsfmt.h"#include "ra8_io_vfs.h"#include "ra8_io_vfs_internal.h"Go to the source code of this file.
Functions | |
| ra8_err_t | ra8_io_vfs_unlink (const char *path) |
| Delete a file by "name:/path". | |
| static ra8_err_t | internal_vfs_rename_split (const char *old_path, const char *new_path, char *old_name, char *new_name, const char **out_old_sub, const char **out_new_sub) |
| Split both rename paths and require them to name the same mount. | |
| ra8_err_t | ra8_io_vfs_rename (const char *old_path, const char *new_path) |
| Rename a file within one mount. | |
| ra8_err_t | ra8_io_vfs_stat (const char *path, ra8_io_vfs_stat_t *out) |
| Query metadata for "name:/path". | |
| ra8_err_t | ra8_io_vfs_listdir (const char *path, ra8_fs_listdir_cb_t cb, void *ctx) |
| Enumerate a directory named "name:/path". | |
| ra8_err_t | ra8_io_vfs_dir_requirements (const char *path, uint32_t *out_bytes, uint8_t *out_align, uint16_t *out_max_open) |
| Query cursor workspace requirements for a qualified directory path. | |
| ra8_err_t | ra8_io_vfs_dir_open (const char *path, ra8_io_vfs_dir_t *directory, void *workspace, uint32_t workspace_bytes) |
| Open a format-neutral incremental directory cursor. | |
| ra8_err_t | ra8_io_vfs_dir_next (ra8_io_vfs_dir_t *directory, ra8_fs_dirent_t *out, bool *out_entry) |
| Copy one stable entry or report clean end-of-directory. | |
| ra8_err_t | ra8_io_vfs_dir_close (ra8_io_vfs_dir_t *directory) |
| Close and consume one caller-owned VFS directory cursor. | |
| ra8_err_t | ra8_io_vfs_mkdir (const char *path) |
| Create a directory named "name:/path". | |
| ra8_err_t | ra8_io_vfs_rmdir (const char *path) |
| Remove the empty directory named "name:/path". | |
Variables | |
| static const char *const | s_tag = "ra8_io_vfs_namespace" |
| Module log tag. | |
Path-namespace operations over the ra8_io VFS named-mount table.
Owns every request that names an entry rather than holds one open: removal, same-mount rename, metadata, directory listing, bounded directory cursors, and directory creation and removal. Each call resolves "name:sub" to a mount slot through priv_ra8_io_vfs_resolve, checks the mount format's advertised capability explicitly, then dispatches to that format's ra8_io_fsfmt_ops_t entry. A rename whose two paths name different mounts is refused rather than emulated, because this facade performs no cross-format copy. All storage is caller-owned or lives in the mount table this unit never touches directly.
Definition in file ra8_io_vfs_namespace.c.
|
static |
Split both rename paths and require them to name the same mount.
Renaming across mounts is not a rename this facade supports (it would need a cross-format copy), so both paths must resolve to the identical mount name.
| [in] | old_path | Full VFS path of the existing entry. |
| [in] | new_path | Full VFS path of the desired name. |
| [out] | old_name | Mount-name buffer for old_path, at least k_ra8_io_vfs_name_max bytes. |
| [out] | new_name | Mount-name buffer for new_path, at least k_ra8_io_vfs_name_max bytes. |
| [out] | out_old_sub | Sub-path within the mount for old_path. |
| [out] | out_new_sub | Sub-path within the mount for new_path. |
| k_ra8_ok | Both paths split cleanly and name the same mount. |
| k_ra8_err_invalid_arg | The two paths name different mounts. |
| other | Either path failed to split. |
Definition at line 77 of file ra8_io_vfs_namespace.c.
References k_ra8_err_invalid_arg, k_ra8_ok, priv_ra8_io_vfs_split(), priv_ra8_io_vfs_streq(), RA8_INTERNAL, RA8_RETURN_ON_ERROR, and s_tag.
Referenced by ra8_io_vfs_rename().
|
nodiscard |
Close and consume one caller-owned VFS directory cursor.
Definition at line 234 of file ra8_io_vfs_namespace.c.
References ra8_io_vfs_dir_t::format, ra8_io_vfs_dir_t::is_open, k_ra8_err_invalid_state, k_ra8_err_null_ptr, and ra8_io_vfs_dir_t::state.
Referenced by internal_dir_close().
|
nodiscard |
Copy one stable entry or report clean end-of-directory.
Definition at line 221 of file ra8_io_vfs_namespace.c.
References ra8_io_vfs_dir_t::format, ra8_io_vfs_dir_t::is_open, k_ra8_err_invalid_state, k_ra8_err_null_ptr, and ra8_io_vfs_dir_t::state.
Referenced by internal_dir_next().
|
nodiscard |
Open a format-neutral incremental directory cursor.
| [in] | path | Qualified VFS directory path. |
| [out] | directory | Idle caller-owned cursor facade. |
| [in,out] | workspace | Format-private caller storage. |
| [in] | workspace_bytes | Accessible workspace extent. |
Definition at line 182 of file ra8_io_vfs_namespace.c.
References ra8_io_fsfmt_caps_t::directory_workspace_align, vfs_slot_t::format, ra8_io_vfs_dir_t::is_open, k_ra8_err_busy, k_ra8_err_invalid_arg, k_ra8_err_no_mem, k_ra8_err_not_supported, k_ra8_err_null_ptr, k_ra8_ok, vfs_slot_t::mount_ctx, priv_ra8_io_vfs_resolve(), and ra8_io_fsfmt_caps_t::supports_dir_cursor.
Referenced by internal_dir_open().
|
nodiscard |
Query cursor workspace requirements for a qualified directory path.
| [in] | path | Qualified VFS path whose mount selects the format. |
| [out] | out_bytes | Required caller workspace bytes. |
| [out] | out_align | Required power-of-two workspace alignment. |
| [out] | out_max_open | Maximum concurrently open cursors. |
| k_ra8_err_not_supported | The mounted format declines cursor support. |
path are non-NULL. Definition at line 154 of file ra8_io_vfs_namespace.c.
References vfs_slot_t::format, k_ra8_err_not_supported, k_ra8_err_null_ptr, k_ra8_ok, and priv_ra8_io_vfs_resolve().
Referenced by internal_dir_requirements().
|
nodiscard |
Enumerate a directory named "name:/path".
| [in] | path | "name:/path" directory string ("name:/" for the root). |
| [in] | cb | Per-entry callback (non-NULL). |
| [in] | ctx | Cookie forwarded to cb. |
| k_ra8_ok | Enumeration complete. |
| k_ra8_err_null_ptr | path or cb was NULL. |
| k_ra8_err_invalid_arg | path has no name: prefix. |
| k_ra8_err_not_found | The mount name is absent. |
| k_ra8_err_* | Propagated from ra8_fs_listdir. |
Definition at line 144 of file ra8_io_vfs_namespace.c.
References vfs_slot_t::format, vfs_slot_t::mount_ctx, priv_ra8_io_vfs_resolve(), RA8_CHECK_NULL_PTR, RA8_RETURN_ON_ERROR, and s_tag.
Referenced by internal_listdir().
|
nodiscard |
Create a directory named "name:/path".
Routes to the named mount and delegates to ra8_fs_mkdir, which creates the final path component as a new directory. Nested paths are supported on FAT12/16/32 and exFAT when every intermediate component already exists.
| [in] | path | "name:/path" directory string. |
| k_ra8_ok | Directory created. |
| k_ra8_err_null_ptr | path was NULL. |
| k_ra8_err_invalid_arg | path has no name: prefix, or a bad leaf. |
| k_ra8_err_not_found | The mount name or a path component is absent. |
| k_ra8_err_exists | The directory already exists. |
Definition at line 247 of file ra8_io_vfs_namespace.c.
References vfs_slot_t::format, k_ra8_err_not_supported, vfs_slot_t::mount_ctx, priv_ra8_io_vfs_resolve(), RA8_CHECK_NULL_PTR, RA8_RETURN_ON_ERROR, and s_tag.
Referenced by internal_mkdir(), internal_mount_sd(), ra8_io_roundtrip_subdir_file(), and sdhi_demo_roundtrip().
|
nodiscard |
Rename a file within one mount.
| [in] | old_path | "name:/old" string. |
| [in] | new_path | "name:/new" string (same mount as old_path). |
| k_ra8_ok | File renamed. |
| k_ra8_err_null_ptr | Either argument was NULL. |
| k_ra8_err_invalid_arg | Missing prefix, or the two mounts differ. |
| k_ra8_err_not_found | The mount or old_path is absent. |
| k_ra8_err_exists | new_path already exists. |
Definition at line 92 of file ra8_io_vfs_namespace.c.
References vfs_slot_t::format, internal_vfs_rename_split(), k_ra8_err_not_found, k_ra8_err_not_supported, k_ra8_io_vfs_name_max, k_ra8_ok, vfs_slot_t::mount_ctx, priv_ra8_io_vfs_find(), RA8_CHECK_NULL_PTR, and s_tag.
Referenced by internal_commit(), and internal_rename().
|
nodiscard |
Remove the empty directory named "name:/path".
Routes to the named mount and delegates to ra8_fs_rmdir, which removes the final path component when it is an existing directory holding no live entries. FAT's own "." and ".." links are ignored; exFAT has no dot entries. The volume root and plain files are refused.
| [in] | path | "name:/path" directory string. |
| k_ra8_ok | Directory removed. |
| k_ra8_err_null_ptr | path was NULL. |
| k_ra8_err_invalid_arg | path has no name: prefix, names the root, or names a file. |
| k_ra8_err_not_found | The mount name or a path component is absent. |
| k_ra8_err_not_empty | The directory still holds entries. |
Definition at line 265 of file ra8_io_vfs_namespace.c.
References vfs_slot_t::format, k_ra8_err_not_supported, vfs_slot_t::mount_ctx, priv_ra8_io_vfs_resolve(), RA8_CHECK_NULL_PTR, RA8_RETURN_ON_ERROR, and s_tag.
Referenced by internal_rmdir().
|
nodiscard |
Query metadata for "name:/path".
Delegates to ra8_fs_stat(), which reads the directory entry without opening it. A directory therefore reports is_directory == true and size_bytes == 0, and attr is the entry's real attribute byte – read-only, hidden and system all survive the trip. A missing name is k_ra8_ok with exists == false, not an error: absence is an answer.
"name:/" names the volume root, which always exists and is always a directory.
| [in] | path | "name:/path" string. |
| [out] | out | Metadata snapshot (exists reflects presence). |
| k_ra8_ok | Metadata resolved (exists may be false). |
| k_ra8_err_null_ptr | path or out was NULL. |
| k_ra8_err_invalid_arg | path has no name: prefix, or a component is not a valid 8.3 name. |
| k_ra8_err_not_found | The mount name is absent. |
Definition at line 118 of file ra8_io_vfs_namespace.c.
References ra8_fs_stat_t::accessed, ra8_io_vfs_stat_t::accessed, ra8_fs_stat_t::attr, ra8_io_vfs_stat_t::attr, ra8_fs_stat_t::created, ra8_io_vfs_stat_t::created, ra8_io_vfs_stat_t::exists, vfs_slot_t::format, ra8_fs_stat_t::is_directory, ra8_io_vfs_stat_t::is_directory, k_ra8_err_not_found, k_ra8_ok, ra8_fs_stat_t::modified, ra8_io_vfs_stat_t::modified, vfs_slot_t::mount_ctx, priv_ra8_io_vfs_resolve(), RA8_CHECK_NULL_PTR, RA8_RETURN_ON_ERROR, s_tag, ra8_fs_stat_t::size_bytes, and ra8_io_vfs_stat_t::size_bytes.
Referenced by internal_abort_stage(), internal_final_absent(), internal_mount_sd(), internal_parent_check(), internal_remove_stale_stage(), internal_staged_file_check(), and internal_stat().
|
nodiscard |
Delete a file by "name:/path".
| [in] | path | "name:/path" string. |
| k_ra8_ok | File unlinked. |
| k_ra8_err_null_ptr | path was NULL. |
| k_ra8_err_invalid_arg | path has no name: prefix. |
| k_ra8_err_not_found | The mount name or the file is absent. |
Definition at line 38 of file ra8_io_vfs_namespace.c.
References vfs_slot_t::format, k_ra8_err_not_supported, vfs_slot_t::mount_ctx, priv_ra8_io_vfs_resolve(), RA8_CHECK_NULL_PTR, RA8_RETURN_ON_ERROR, and s_tag.
Referenced by internal_abort_stage(), internal_remove_stale_stage(), and internal_unlink().
|
static |
Module log tag.
Definition at line 36 of file ra8_io_vfs_namespace.c.