30static const char*
const s_tag =
"ra8_io_fsfmt";
292 bool present =
false;
333 void* directory_state,
334 uint32_t state_bytes)
580 .max_open_directories = UINT16_MAX,
581 .directory_workspace_align = (uint8_t)_Alignof(
ra8_fs_dir_t),
583 .supports_mkdir =
true,
584 .supports_rmdir =
true,
585 .supports_streaming_write =
true,
586 .supports_timestamps =
true,
587 .supports_free_space =
true,
588 .supports_dir_cursor =
true,
589 .supports_sync =
false,
590 .atomic_rename =
false,
591 .durable_sync =
false,
592 .unicode_names =
true,
593 .case_sensitive =
false,
630 .max_open_directories = UINT16_MAX,
631 .directory_workspace_align = (uint8_t)_Alignof(
ra8_fs_dir_t),
633 .supports_mkdir =
true,
634 .supports_rmdir =
true,
635 .supports_streaming_write =
true,
636 .supports_timestamps =
true,
637 .supports_free_space =
true,
638 .supports_dir_cursor =
true,
639 .supports_sync =
false,
640 .atomic_rename =
false,
641 .durable_sync =
false,
642 .unicode_names =
true,
643 .case_sensitive =
false,
669 const uint8_t align = fmt->caps.directory_workspace_align;
670 if ((fmt->ops->dir_open ==
nullptr) || (fmt->ops->dir_next ==
nullptr) ||
671 (fmt->ops->dir_close ==
nullptr) || (fmt->caps.directory_workspace_bytes == 0U) ||
672 (fmt->caps.max_open_directories == 0U) || (align == 0U) ||
673 (((uint32_t)align & ((uint32_t)align - 1U)) != 0U)) {
710 if (fmt->caps.supports_streaming_write) {
711 if (fmt->ops->write ==
nullptr) {
715 if (fmt->caps.supports_mkdir) {
716 if (fmt->ops->mkdir ==
nullptr) {
720 if (fmt->caps.supports_rmdir) {
721 if (fmt->ops->rmdir ==
nullptr) {
725 if (fmt->caps.supports_free_space) {
726 if (fmt->ops->free_space ==
nullptr) {
730 if (fmt->caps.supports_sync) {
731 if (fmt->ops->sync ==
nullptr) {
735 if (fmt->caps.atomic_rename) {
736 if (fmt->ops->rename ==
nullptr) {
764 if (fmt->caps.supports_dir_cursor) {
767 "dir-cursor capability mismatch");
770 if (fmt->caps.durable_sync) {
771 if (!fmt->caps.supports_sync) {
863 "missing mandatory operation");
908 for (uint32_t i = 0U; i <
s_count; ++i) {
909 if (
s_reg[i]->ops->probe(backend)) {
static const char * s_tag
Logging / check tag.
Annotation-attribute framework macros for ra8-firmware.
#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_no_mem
Static buffer exhausted (no dynamic memory on this project).
@ k_ra8_err_invalid_arg
Invalid function argument.
@ 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).
ra8_err_t ra8_fs_dir_next(ra8_fs_dir_t *directory, ra8_fs_dirent_t *out, bool *out_entry)
Copy the next visible directory entry.
ra8_err_t ra8_fs_rename(const ra8_fs_mount_t *handle, const char *old_path, const char *new_path)
Rename a file within its own directory.
ra8_err_t ra8_fs_write(ra8_fs_file_t *file, const uint8_t *buf, uint32_t len)
Write len bytes; allocate new clusters from FAT free-space scan as needed.
ra8_err_t ra8_fs_mount(const ra8_fs_backend_t *backend, ra8_fs_mount_t **out_handle)
Mount a FAT volume from a block-device backend, auto-selecting the first partition.
ra8_err_t ra8_fs_size(const ra8_fs_file_t *file, uint64_t *out_bytes)
Report the file's size in bytes (64-bit on exFAT, #676).
ra8_err_t ra8_fs_read(ra8_fs_file_t *file, uint8_t *buf, uint32_t max_len, uint32_t *got_len)
Read up to max_len bytes; advance the cluster chain on cluster crossings.
ra8_err_t ra8_fs_stat(const ra8_fs_mount_t *handle, const char *path, ra8_fs_stat_t *out)
Report what a path names – file or directory – without opening it.
ra8_err_t ra8_fs_unlink(const ra8_fs_mount_t *handle, const char *path)
Delete a file: mark its dir entry deleted and free its clusters.
ra8_err_t ra8_fs_open(ra8_fs_mount_t *handle, const char *path, ra8_fs_mode_t mode, ra8_fs_file_t **out_file)
Open or create a file by path, 8.3 or long.
ra8_err_t ra8_fs_unmount(ra8_fs_mount_t *handle)
Unmount a previously mounted volume and release its slot.
ra8_err_t ra8_fs_mkdir(const ra8_fs_mount_t *handle, const char *path)
Create a directory at path.
ra8_err_t ra8_fs_rmdir(const ra8_fs_mount_t *handle, const char *path)
Remove an empty directory at path.
ra8_err_t ra8_fs_probe(const ra8_fs_backend_t *backend, ra8_fs_type_t *out_type)
Identify a FAT/exFAT volume without claiming a mount slot.
ra8_err_t ra8_fs_close(ra8_fs_file_t *file)
Close an open file, stamping its final modification time.
ra8_err_t ra8_fs_seek(ra8_fs_file_t *file, uint64_t offset_bytes)
Move the file offset to offset_bytes (clamped to size).
ra8_err_t ra8_fs_tell(const ra8_fs_file_t *file, uint64_t *out_offset)
Report the current offset (64-bit; see ra8_fs_seek).
ra8_err_t ra8_fs_dir_close(ra8_fs_dir_t *directory)
Consume one open directory cursor.
ra8_err_t ra8_fs_dir_open(ra8_fs_mount_t *handle, const char *path, ra8_fs_dir_t *directory)
Open a caller-owned directory cursor without holding the filesystem lock.
ra8_fs_type_t
FAT variant detected from the BPB cluster-count rule.
@ k_ra8_fs_type_fat12
count_of_clusters < 4085.
@ k_ra8_fs_type_fat32
count_of_clusters >= 65525.
@ k_ra8_fs_type_exfat
exFAT (read + streaming write + format).
@ k_ra8_fs_type_fat16
4085 <= count_of_clusters < 65525.
@ k_ra8_fs_type_unknown
Not yet detected / mount failed.
ra8_fs_mode_t
File-open modes accepted by ra8_fs_open().
void(* ra8_fs_listdir_cb_t)(const char *name, uint8_t attr, uint64_t size, void *ctx)
Callback invoked once per directory entry by ra8_fs_listdir().
static bool internal_exfat_probe(const ra8_fs_backend_t *backend)
Test whether the authoritative native parser identifies exFAT.
static ra8_err_t internal_native_mkdir(void *mount_ctx, const char *path)
Create a native ra8_fs directory.
static ra8_err_t internal_native_rename(void *mount_ctx, const char *old_path, const char *new_path)
Rename inside one native ra8_fs mount.
static ra8_err_t internal_native_write(void *file_ctx, const void *buf, uint32_t bytes)
Write a native ra8_fs stream.
static const ra8_io_fsfmt_t s_fmt_exfat
Native exFAT descriptor.
static ra8_err_t internal_native_free_space(void *mount_ctx, ra8_fs_space_t *out)
Query native ra8_fs free space.
static ra8_err_t internal_native_dir_next(void *directory_state, ra8_fs_dirent_t *out, bool *out_entry)
Copy one native directory-cursor entry without retaining a lock.
static const ra8_io_fsfmt_ops_t s_exfat_ops
Native exFAT descriptor; shares byte-identical ra8_fs dispatch.
static ra8_err_t internal_native_rmdir(void *mount_ctx, const char *path)
Remove a native ra8_fs directory.
static ra8_err_t internal_validate_required_ops_group2(const ra8_io_fsfmt_t *fmt)
Validate that the remaining five mandatory format operations are present.
static ra8_err_t internal_validate_caps(const ra8_io_fsfmt_t *fmt)
Validate every optional capability flag against its backing operation.
ra8_err_t ra8_io_fsfmt_init(void)
Reset the registry and register the built-in FAT + exFAT formats.
static const ra8_io_fsfmt_t s_fmt_fat
Native FAT12/16/32 descriptor.
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.
static ra8_err_t internal_native_read(void *file_ctx, void *buf, uint32_t bytes, uint32_t *out_read)
Read a native ra8_fs stream.
static const ra8_io_fsfmt_ops_t s_native_ops
Complete native operation table; no explicit durable-sync seam exists.
static const ra8_io_fsfmt_t * s_reg[(uint32_t) k_ra8_io_fsfmt_max]
Registered formats, in probe priority order.
static ra8_err_t internal_validate_required_ops_group1(const ra8_io_fsfmt_t *fmt)
Validate that the first six mandatory format operations are present.
static ra8_err_t internal_native_close(void *file_ctx)
Close a native ra8_fs stream.
static ra8_err_t internal_native_size(const void *file_ctx, uint64_t *out_bytes)
Report a native ra8_fs stream size.
ra8_err_t ra8_io_fsfmt_register(const ra8_io_fsfmt_t *fmt)
Register a filesystem format (the foreign-format seam).
static uint32_t s_count
Occupied entries in s_reg.
static ra8_err_t internal_native_mount(const ra8_fs_backend_t *backend, void **out_mount)
Mount the native ra8_fs implementation without pointer aliasing.
static ra8_err_t internal_native_open(void *mount_ctx, const char *path, ra8_fs_mode_t mode, void **out_file)
Open a native ra8_fs stream without pointer aliasing.
static ra8_err_t internal_native_dir_open(void *mount_ctx, const char *path, void *directory_state, uint32_t state_bytes)
Open one native incremental directory cursor.
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.
static ra8_err_t internal_native_stat(void *mount_ctx, const char *path, ra8_fs_stat_t *out)
Query native ra8_fs metadata.
static ra8_err_t internal_native_tell(const void *file_ctx, uint64_t *out_offset)
Report a native ra8_fs stream offset.
static bool internal_fat_probe(const ra8_fs_backend_t *backend)
Test whether the authoritative native parser identifies a FAT variant.
static ra8_err_t internal_native_unlink(void *mount_ctx, const char *path)
Unlink a native ra8_fs file.
static ra8_err_t internal_validate_single_op_caps(const ra8_io_fsfmt_t *fmt)
Validate that every claimed optional capability has an operation.
static ra8_err_t internal_validate_required_ops(const ra8_io_fsfmt_t *fmt)
Validate that every mandatory format operation pointer is present.
static ra8_err_t internal_native_listdir(void *mount_ctx, const char *path, ra8_fs_listdir_cb_t cb, void *cb_ctx)
Enumerate a native ra8_fs directory.
static ra8_err_t internal_native_unmount(void *mount_ctx)
Release a native ra8_fs mount.
static ra8_err_t internal_native_seek(void *file_ctx, uint64_t offset_bytes)
Seek a native ra8_fs stream.
static ra8_err_t internal_native_dir_close(void *directory_state)
Close and consume one native directory cursor.
static ra8_err_t internal_validate_dir_cursor_caps(const ra8_io_fsfmt_t *fmt)
Validate that a claimed directory-cursor capability is complete.
ra8_io pluggable filesystem-format registry (probe + capabilities).
@ k_ra8_io_fsfmt_exfat_max_name_utf8
64 UTF-16 units, worst case.
@ k_ra8_io_fsfmt_fat_max_name_utf8
247 UTF-16 units, worst case.
@ k_ra8_io_fsfmt_max
Max registered formats (built-ins + foreign).
Block-device interface that ra8_fs runs on top of.
Caller-owned opaque directory cursor.
bool is_open
Facade lifecycle guard.
Stable directory-entry value copied by ra8_fs_dir_next.
char name[k_ra8_fs_dir_name_cap]
NUL-terminated visible leaf.
uint8_t attr
On-disk FAT attributes.
uint64_t size_bytes
File bytes; zero for dirs.
Cached parse of one mounted FAT volume.
A mounted volume's capacity, free space, and cluster geometry.
What ra8_fs_stat() read out of a directory entry.
Complete filesystem-format dispatch surface used by the VFS.
One registered filesystem format.