ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_io_vfs_internal.h File Reference

Module-private mount-slot layout and path resolvers for the ra8_io VFS. More...

#include <stdint.h>
#include "ra8_attributes.h"
#include "ra8_err.h"
#include "ra8_io_fsfmt.h"
#include "ra8_io_vfs.h"
Include dependency graph for ra8_io_vfs_internal.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  vfs_slot_t
 One fixed named-mount slot. More...

Functions

ra8_err_t ra8_io_vfs_init_slot_test (vfs_slot_t *slot)
 Test-only entry point for internal_vfs_init_slot().
bool priv_ra8_io_vfs_streq (const char *a, const char *b)
 Compare two mount names within the fixed bound.
vfs_slot_tpriv_ra8_io_vfs_find (const char *name, uint8_t *out_index)
 Find an occupied mount slot by name and optionally report its index.
ra8_err_t priv_ra8_io_vfs_split (const char *path, char *out_name, const char **out_sub)
 Split "name:sub" into a bounded name and sub-path pointer.
ra8_err_t priv_ra8_io_vfs_resolve (const char *path, vfs_slot_t **out_slot, uint8_t *out_index, const char **out_sub)
 Resolve "name:sub" to a mount slot and sub-path.

Detailed Description

Module-private mount-slot layout and path resolvers for the ra8_io VFS.

Tag
[Ring 4 / PAL] {World: NS}

The named-mount dispatcher is implemented by two translation units. The mount table, its fixed storage, and the open-stream facade live in ra8_io_vfs.c; the path-namespace operations (removal, rename, metadata, listing, directory cursors, and directory creation) live in ra8_io_vfs_namespace.c. Both need the fixed slot layout and the bounded name/path resolvers declared here.

The mount and open-file tables themselves stay private to ra8_io_vfs.c: the namespace unit reaches a mount only through priv_ra8_io_vfs_find and priv_ra8_io_vfs_resolve, so there is exactly one owner of that state.

Since
0.1.0

Definition in file ra8_io_vfs_internal.h.

Function Documentation

◆ priv_ra8_io_vfs_find()

vfs_slot_t * priv_ra8_io_vfs_find ( const char * name,
uint8_t * out_index )

Find an occupied mount slot by name and optionally report its index.

Searches the fixed mount table in ascending slot order.

Parameters
[in]nameValid mount name.
[out]out_indexOptional slot-index destination.
Returns
vfs_slot_t* Matching slot or NULL.
Return values
non-NULLOccupied matching slot.
NULLNo slot matched.
Precondition
name is non-NULL and bounded.
out_index is NULL or writable.
Postcondition
On a match the optional index identifies the returned slot.
Mount-table state is unchanged.
Note
Not thread-safe with concurrent mount mutation.
Since
0.1.0

Definition at line 120 of file ra8_io_vfs.c.

References k_ra8_io_vfs_max_mounts, priv_ra8_io_vfs_streq(), RA8_PRIV, and s_table.

Referenced by priv_ra8_io_vfs_resolve(), ra8_io_vfs_free_space(), ra8_io_vfs_get_caps(), ra8_io_vfs_mount(), ra8_io_vfs_mount_auto(), ra8_io_vfs_rename(), and ra8_io_vfs_unmount().

◆ priv_ra8_io_vfs_resolve()

ra8_err_t priv_ra8_io_vfs_resolve ( const char * path,
vfs_slot_t ** out_slot,
uint8_t * out_index,
const char ** out_sub )

Resolve "name:sub" to a mount slot and sub-path.

Splits the prefix then looks up the named fixed-table slot.

Parameters
[in]pathQualified VFS path.
[out]out_slotReceives the mounted slot.
[out]out_indexOptional slot-index destination.
[out]out_subReceives the volume-relative sub-path.
Returns
ra8_err_t Resolution result.
Return values
k_ra8_okMount resolved.
k_ra8_err_not_foundName is not mounted.
k_ra8_err_invalid_argPath cannot be split.
Precondition
path, out_slot, and out_sub are non-NULL.
out_index is NULL or writable.
Postcondition
On success the slot and sub-path outputs are assigned.
Mount-table state is unchanged.
Note
Not thread-safe with concurrent unmount.
Since
0.1.0

Definition at line 181 of file ra8_io_vfs.c.

References k_ra8_err_not_found, k_ra8_io_vfs_name_max, k_ra8_ok, priv_ra8_io_vfs_find(), priv_ra8_io_vfs_split(), and RA8_PRIV.

Referenced by internal_vfs_file_open_resolve(), internal_vfs_open_resolve(), ra8_io_vfs_dir_open(), ra8_io_vfs_dir_requirements(), ra8_io_vfs_listdir(), ra8_io_vfs_mkdir(), ra8_io_vfs_rmdir(), ra8_io_vfs_stat(), and ra8_io_vfs_unlink().

◆ priv_ra8_io_vfs_split()

ra8_err_t priv_ra8_io_vfs_split ( const char * path,
char * out_name,
const char ** out_sub )

Split "name:sub" into a bounded name and sub-path pointer.

Finds the colon within the name bound and copies only the prefix.

Parameters
[in]pathQualified VFS path.
[out]out_nameFixed mount-name buffer.
[out]out_subReceives a pointer after the colon.
Returns
ra8_err_t Split result.
Return values
k_ra8_okPath split.
k_ra8_err_invalid_argNo bounded colon exists.
Precondition
All pointers are non-NULL.
out_name has VFS-name capacity.
Postcondition
On success both outputs are assigned.
No mount-table state is modified.
Note
The sub-path aliases the caller's input string.
Since
0.1.0

Definition at line 160 of file ra8_io_vfs.c.

References k_ra8_err_invalid_arg, k_ra8_io_vfs_name_max, k_ra8_ok, and RA8_PRIV.

Referenced by internal_vfs_rename_split(), and priv_ra8_io_vfs_resolve().

◆ priv_ra8_io_vfs_streq()

bool priv_ra8_io_vfs_streq ( const char * a,
const char * b )

Compare two mount names within the fixed bound.

Stops at the first mismatch or shared terminator.

Parameters
[in]aFirst name.
[in]bSecond name.
Returns
bool Equality result.
Return values
trueNames are equal.
falseNames differ.
Precondition
a and b are non-NULL.
Both names terminate within the VFS name bound.
Postcondition
No state is modified.
At most the fixed name bound is inspected.
Note
Pure bounded comparison.
Since
0.1.0

Definition at line 45 of file ra8_io_vfs.c.

References k_ra8_io_vfs_name_max, and RA8_PRIV.

Referenced by internal_vfs_rename_split(), and priv_ra8_io_vfs_find().

◆ ra8_io_vfs_init_slot_test()

ra8_err_t ra8_io_vfs_init_slot_test ( vfs_slot_t * slot)

Test-only entry point for internal_vfs_init_slot().

Exists so the reset-and-conditionally-unmount decision can be driven directly against a caller-built vfs_slot_t, without routing through ra8_io_vfs_mount / ra8_io_vfs_mount_auto to reach every in_use / owned combination.

Parameters
[in,out]slotMount slot to tear down and reset.
Returns
The owned unmount's status, or k_ra8_ok when no unmount was needed.
Return values
k_ra8_okThe slot was already idle, borrowed, or unmounted cleanly.
otherThe bound format's unmount reported a failure.
Precondition
slot is non-NULL.
When slot->in_use && slot->owned, slot->format->ops->unmount is non-NULL.
Postcondition
slot is zero-initialized.
An owned mount's format unmount is invoked exactly once.
Note
Not thread-safe; single-threaded host test use only.
MC/DC:
Exposes internal_vfs_init_slot()'s slot->in_use && slot->owned decision (libs/ra8_io/src/ra8_io_vfs.c@internal_vfs_init_slot) for direct N+1 vectors; see internal_test_vfs_init_slot_mcdc in tests/storage/src/test_ra8_io_vfs.c.
Since
Version 0.1.0

Test-only entry point for internal_vfs_init_slot().

Definition at line 398 of file ra8_io_vfs.c.

References internal_vfs_init_slot(), and RA8_TEST_HELPER.