30static const char*
const s_tag =
"ra8_io_vfs";
77 const char c = name[i];
113 if (src[i] ==
'\0') {
127 if (out_index !=
nullptr) {
128 *out_index = (uint8_t)i;
164 const char c = path[i];
177 *out_sub = &path[i + 1U];
184 const char** out_sub)
192 if (slot ==
nullptr) {
218 if (format == native) {
222 return format == native;
307 if (format->caps.read_only) {
310 if (!format->caps.supports_streaming_write) {
313 if (format->ops->write ==
nullptr) {
360 if (file ==
nullptr) {
429 if (slot ==
nullptr) {
459 void** out_mount_ctx)
477 if (slot ==
nullptr) {
481 void* mount_ctx =
nullptr;
495 if (slot ==
nullptr) {
500 if (
s_files[i].mount_index == index) {
537 const char** out_sub)
540 if (!(*out_slot)->native) {
552 const char* sub =
nullptr;
557 void* file_ctx =
nullptr;
589 const char** out_sub)
604 const char* sub =
nullptr;
610 if (file ==
nullptr) {
613 void* file_ctx =
nullptr;
617 file->format = slot->
format;
618 file->file_ctx = file_ctx;
619 file->mount_index = index;
631 const ra8_err_t e = file->format->ops->close(file->file_ctx);
645 return file->format->ops->read(file->file_ctx, buf, bytes, out_read);
655 if (file->format->caps.read_only) {
658 if (!file->format->caps.supports_streaming_write) {
661 if (file->format->ops->write ==
nullptr) {
664 return file->format->ops->write(file->file_ctx, buf, bytes);
673 return file->format->ops->seek(file->file_ctx, offset_bytes);
683 return file->format->ops->tell(file->file_ctx, out_offset);
693 return file->format->ops->size(file->file_ctx, out_bytes);
702 if (!file->format->caps.supports_sync) {
705 if (file->format->ops->sync ==
nullptr) {
708 return file->format->ops->sync(file->file_ctx);
716 if (slot ==
nullptr) {
719 *out = slot->
format->caps;
728 if (slot ==
nullptr) {
731 if (!slot->
format->caps.supports_free_space) {
734 if (slot->
format->ops->free_space ==
nullptr) {
static const char * s_tag
Logging / check tag.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_PRIV
Module-private helper: shared across TUs but only inside one library.
#define RA8_TEST_HELPER
Mark a symbol as externally-linked but only callable from tests.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_RETURN_ON_ERROR(err, tag, message)
Early return on error, propagating the code upward.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_not_supported
Requested feature not compiled in, not wired, or not supported by this MCU variant.
@ k_ra8_err_no_mem
Static buffer exhausted (no dynamic memory on this project).
@ k_ra8_err_busy
Resource busy – blocking operation cannot proceed.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_err_exists
Item already exists – cannot create again.
@ k_ra8_err_invalid_state
Module in wrong state for requested operation.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_not_found
Requested item not found (lookup / search missed).
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Minimal FAT12/FAT16/FAT32 filesystem adapter (read + write).
static ra8_fs_file_t s_files[k_ra8_fs_max_files]
File handle table – max k_ra8_fs_max_files open at once.
@ k_ra8_fs_type_exfat
exFAT (read + streaming write + format).
@ k_ra8_fs_type_fat16
4085 <= count_of_clusters < 65525.
ra8_fs_mode_t
File-open modes accepted by ra8_fs_open().
@ k_ra8_fs_mode_append
Open at EOF for writing.
@ k_ra8_fs_mode_read
Read-only, must exist.
@ k_ra8_fs_mode_write
Truncate (or create) for writing.
ra8_io pluggable filesystem-format registry (probe + capabilities).
ra8_err_t ra8_io_fsfmt_probe(const ra8_fs_backend_t *backend, const ra8_io_fsfmt_t **out)
Detect the format of a volume by probing registered formats in order.
ra8_err_t ra8_io_fsfmt_get_builtin(ra8_fs_type_t type, const ra8_io_fsfmt_t **out)
Return the built-in descriptor serving one native ra8_fs type.
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.
static void internal_store_mount(vfs_slot_t *slot, const char *name, const ra8_io_fsfmt_t *format, void *mount_ctx, bool owned)
Populate a previously selected free mount slot.
static ra8_err_t internal_vfs_init_slot(vfs_slot_t *slot)
Reset one mount slot for global reinit, unmounting it first if owned.
ra8_err_t ra8_io_vfs_mount(const char *name, ra8_fs_mount_t *mount)
Register a mounted volume under a name.
ra8_err_t ra8_io_vfs_free_space(const char *name, ra8_fs_space_t *out)
Query free and total bytes through a mounted format's ops.
ra8_err_t ra8_io_vfs_init_slot_test(vfs_slot_t *slot)
Implementation of ra8_io_vfs_init_slot_test().
ra8_err_t ra8_io_vfs_open(const char *path, ra8_fs_mode_t mode, ra8_fs_file_t **out_file)
Open a file by "name:/path".
ra8_err_t ra8_io_vfs_file_close(ra8_io_vfs_file_t *file)
Close and always release one format-neutral stream facade.
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.
static bool internal_is_native(const ra8_io_fsfmt_t *format)
Test whether a descriptor is one of the native ra8_fs built-ins.
bool priv_ra8_io_vfs_streq(const char *a, const char *b)
Compare two mount names within the fixed bound.
ra8_err_t ra8_io_vfs_file_size(const ra8_io_vfs_file_t *file, uint64_t *out_bytes)
Report a format-neutral stream's size.
static ra8_err_t internal_vfs_open_resolve(const char *path, ra8_fs_mode_t mode, vfs_slot_t **out_slot, const char **out_sub)
Resolve a raw-open path and require the target format be native.
ra8_err_t ra8_io_vfs_get_caps(const char *name, ra8_io_fsfmt_caps_t *out)
Copy the truthful capabilities of a named mounted format.
static bool internal_name_ok(const char *name)
Validate a non-empty bounded mount name with no path separators.
ra8_err_t ra8_io_vfs_file_sync(ra8_io_vfs_file_t *file)
Explicitly sync a stream, or return not-supported when unavailable.
ra8_err_t ra8_io_vfs_mount_auto(const char *name, const ra8_fs_backend_t *backend)
Probe and mount a block backend through the registered format ops.
static void internal_copy_name(char *dst, const char *src)
Copy one already-validated mount name into a fixed slot.
ra8_err_t ra8_io_vfs_file_open(const char *path, ra8_fs_mode_t mode, ra8_io_vfs_file_t **out_file)
Open a format-neutral stream through a mounted format's ops.
static ra8_io_vfs_file_t * internal_free_file(void)
Find one free generic-file facade.
static ra8_err_t internal_vfs_file_open_resolve(const char *path, ra8_fs_mode_t mode, vfs_slot_t **out_slot, uint8_t *out_index, const char **out_sub)
Resolve a facade-open path and require the format support mode.
ra8_err_t ra8_io_vfs_unmount(const char *name)
Remove a named mount from the table.
ra8_err_t ra8_io_vfs_file_read(ra8_io_vfs_file_t *file, void *buf, uint32_t bytes, uint32_t *out_read)
Read bytes through a format-neutral stream.
static vfs_slot_t * internal_free_mount(void)
Find one free mount slot.
static bool internal_file_valid(const ra8_io_vfs_file_t *file)
Verify a facade is currently owned by the fixed file table.
static bool internal_mode_valid(ra8_fs_mode_t mode)
Test whether a value is one of the three public stream modes.
ra8_err_t ra8_io_vfs_file_seek(ra8_io_vfs_file_t *file, uint64_t offset_bytes)
Seek a format-neutral stream.
static ra8_err_t internal_vfs_probe_and_mount(const ra8_fs_backend_t *backend, const ra8_io_fsfmt_t **out_format, void **out_mount_ctx)
Probe a backend's format and mount it through that format, guarded.
ra8_err_t ra8_io_vfs_file_tell(const ra8_io_vfs_file_t *file, uint64_t *out_offset)
Report a format-neutral stream's current offset.
static vfs_slot_t s_table[(uint32_t) k_ra8_io_vfs_max_mounts]
Fixed mount table.
ra8_err_t ra8_io_vfs_init(void)
Reset the VFS mount table to empty.
static ra8_err_t internal_can_open(const ra8_io_fsfmt_t *format, ra8_fs_mode_t mode)
Capability-gate a requested open mode.
ra8_err_t ra8_io_vfs_file_write(ra8_io_vfs_file_t *file, const void *buf, uint32_t bytes)
Write bytes, or return not-supported when capability-gated.
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.
ra8_io virtual filesystem – mount many volumes, address them by name.
@ k_ra8_io_vfs_max_mounts
Concurrent named mounts.
@ k_ra8_io_vfs_max_files
Concurrent generic streams.
@ k_ra8_io_vfs_name_max
Mount name length incl NUL.
Module-private mount-slot layout and path resolvers for the ra8_io VFS.
Block-device interface that ra8_fs runs on top of.
Cached parse of one mounted FAT volume.
ra8_fs_type_t type
FAT12 / FAT16 / FAT32.
A mounted volume's capacity, free space, and cluster geometry.
What a filesystem format supports.
One registered filesystem format.
Opaque, statically-pooled format-neutral file stream.
Publicly opaque stream facade, drawn from s_files.
uint8_t mount_index
Owning mount slot.
const ra8_io_fsfmt_t * format
Format owning file_ctx.
void * file_ctx
Format-private open-file state.
bool in_use
Facade is occupied.
One fixed named-mount slot.
void * mount_ctx
Format-private mounted context.
const ra8_io_fsfmt_t * format
Selected format descriptor.
bool in_use
Slot is occupied.
bool native
Context is a native ra8_fs mount.
bool owned
VFS must invoke format unmount.
char name[(uint32_t) k_ra8_io_vfs_name_max]
NUL-terminated mount name.