78 file->first_cluster = 0U;
79 file->cur_cluster = 0U;
80 file->walk_cache_idx = 0U;
81 file->walk_cache_cluster = 0U;
82 file->size_bytes = 0U;
84 file->dir_entry_lba = 0U;
85 file->dir_entry_idx = 0U;
86 file->valid_bytes = 0U;
87 file->entry_set_cluster = head->
cluster;
88 file->entry_set_index = head->
index;
89 file->entry_set_count = count;
90 file->alloc_clusters = 0U;
91 file->tail_cluster = 0U;
94 file->no_fat_chain = 1U;
139 file->first_cluster = 0U;
140 file->alloc_clusters = 0U;
141 file->tail_cluster = 0U;
142 file->no_fat_chain = 1U;
145 if (file->no_fat_chain != 0U) {
146 file->alloc_clusters = (uint32_t)((file->size_bytes + cbytes - 1U) / cbytes);
147 file->tail_cluster = file->first_cluster + file->alloc_clusters - 1U;
150 uint32_t clus = file->first_cluster;
167 file->alloc_clusters = owned;
168 file->tail_cluster = clus;
202 file->first_cluster = 0U;
203 file->cur_cluster = 0U;
204 file->walk_cache_idx = 0U;
205 file->walk_cache_cluster = 0U;
206 file->size_bytes = 0U;
207 file->valid_bytes = 0U;
209 file->alloc_clusters = 0U;
210 file->tail_cluster = 0U;
211 file->no_fat_chain = 1U;
304 const uint8_t* file_e,
389 const uint16_t* name,
423 const char* leaf =
nullptr;
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
@ 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_invalid_arg
Invalid function argument.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_access_denied
Operation refused because the target is protected against it.
@ k_ra8_err_protocol_error
Protocol-level error (e.g.
@ 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).
uint32_t priv_rd32(const uint8_t *p)
Decode a little-endian uint32_t from a byte buffer.
ra8_err_t priv_fat_get(const ra8_fs_mount_t *m, uint32_t cluster, uint32_t *out_value)
Fetch the FAT entry for cluster, returning the next-cluster value.
uint8_t priv_is_eoc(const ra8_fs_mount_t *m, uint32_t value)
Test whether value is an end-of-chain marker for this FAT type.
uint64_t priv_rd64(const uint8_t *p)
Decode a little-endian uint64_t from a byte buffer.
uint32_t priv_cluster_bytes(const ra8_fs_mount_t *m)
One mounted volume's cluster size in bytes.
ra8_err_t priv_exfat_resolve_parent(const ra8_fs_mount_t *m, const char *path, exfat_dir_t *out_parent, const char **out_leaf)
Resolve every component of path but the last.
ra8_err_t priv_exfat_free_clusters(const ra8_fs_mount_t *m, const uint8_t *strm)
Implementation of priv_exfat_free_clusters() – run or chain, bitmap only.
ra8_err_t priv_exfat_find_set(const ra8_fs_mount_t *m, const exfat_dir_t *dir, const char *path, exfat_setpos_t *pos, uint32_t max_pos, uint32_t *out_count, uint8_t *file_copy, uint8_t *strm_copy)
Implementation of priv_exfat_find_set() – one aligned walk of a directory.
static void internal_exfat_seed_handle(ra8_fs_file_t *file, ra8_fs_mount_t *m, const exfat_setpos_t *head, uint32_t count, ra8_fs_mode_t mode)
Zero every field of a freshly claimed handle and bind it to its set.
ra8_err_t priv_exfat_open_write(ra8_fs_mount_t *handle, const char *path, ra8_fs_mode_t mode, ra8_fs_file_t **out_file)
Open an exFAT file for writing: create, truncate, or position to append.
static ra8_err_t internal_exfat_truncate(ra8_fs_file_t *file, const uint8_t *strm)
Release a file's clusters and rewrite its entry set empty, in place.
static ra8_err_t internal_exfat_writable_set(uint32_t count)
Reject an entry set this adapter cannot correctly rewrite.
static ra8_err_t internal_exfat_survey_alloc(ra8_fs_file_t *file)
Count a file's clusters and find its tail.
static ra8_err_t internal_exfat_open_found(ra8_fs_mount_t *handle, ra8_fs_mode_t mode, const exfat_setpos_t *head, uint32_t count, const uint8_t *file_e, const uint8_t *strm, ra8_fs_file_t **out_file)
Open an existing name for writing: truncate it, or park at its end.
static ra8_err_t internal_exfat_open_created(ra8_fs_mount_t *handle, const exfat_dir_t *dir, const uint16_t *name, uint32_t nlen, ra8_fs_mode_t mode, ra8_fs_file_t **out_file)
Create a name that does not exist and open the empty file it names.
ra8_err_t priv_exfat_name_to_units(const ra8_fs_mount_t *m, const char *path, uint16_t *out, uint32_t *out_units)
Convert a caller's exFAT name to code units, refusing what will not fold.
ra8_err_t priv_exfat_flush_set(ra8_fs_file_t *file)
Rewrite a file's entry set from the handle, checksum last.
ra8_err_t priv_exfat_link(const ra8_fs_mount_t *m, const exfat_dir_t *dir, const uint16_t *name, uint32_t nlen, exfat_setpos_t *out_head, uint32_t *out_count)
Lay down a fresh File/Stream/Name entry set and report where it went.
Cross-TU shared declarations for the FAT/exFAT ra8_fs adapter.
ra8_fs_file_t * priv_alloc_file_slot(void)
Allocate a free entry from the file table; returns NULL if full.
@ k_exfat_strm_off_dlen
Stream-ext DataLength (low 32 used).
@ k_exfat_strm_off_clus
Stream-ext FirstCluster.
@ k_exfat_strm_off_flags
Stream-ext GeneralSecondaryFlags.
@ k_exfat_secflag_no_fat
GeneralSecondaryFlags: NoFatChain.
@ k_exfat_entry_bytes
Directory entry size.
@ k_exfat_off_strm_valid
Stream entry: ValidDataLength (8 B).
@ k_exfat_off_file_attr
File entry: FileAttributes (2 bytes).
@ k_exfat_attr_read_only
FileAttributes: read-only.
@ k_exfat_attr_directory
FileAttributes: directory.
@ k_exfat_name_cap
Longest name we store, in UTF-16 units.
@ k_exfat_set_min_entries
The smallest legal set: File+Stream+Name.
@ k_exfat_set_max_entries
1 File + 1 Stream + 17 Name entries.
@ k_exfat_set_writable
1 File + 1 Stream + 5 Name (64 chars).
@ k_cluster_first_data
Cluster numbers start at 2.
ra8_fs_mode_t
File-open modes accepted by ra8_fs_open().
@ k_ra8_fs_mode_write
Truncate (or create) for writing.
Identifies the exFAT directory a lookup, scan or link operates in.
Directory position (cluster + entry index) of one 32-byte entry.
uint32_t index
Entry index within that cluster (0-based).
uint32_t cluster
Directory cluster holding the entry.
uint64_t size_bytes
File size (DIR_FileSize / DataLength).
uint64_t valid_bytes
exFAT ValidDataLength (bytes written).
uint64_t offset
Current read/write offset.
uint32_t first_cluster
Head of the file's cluster chain.
uint8_t in_use
0 = slot free, 1 = open.
uint32_t walk_cache_cluster
Cluster at walk_cache_idx; < 2 = no cache.
uint8_t no_fat_chain
exFAT contiguous file (no FAT walk).
uint32_t cur_cluster
Cluster the offset currently points into.
ra8_fs_mount_t * mount
Owning mount point.
Cached parse of one mounted FAT volume.
uint32_t count_of_clusters
Per MS spec: data_sectors / SPC.