96 for (uint32_t i = 0U; i < len; i++) {
104 uint32_t nunits = 0U;
148 const char** out_leaf)
150 const char* p = path;
159 while (*end !=
'\0') {
188 const char* p = path;
197 const char* leaf =
nullptr;
215 const char* leaf =
nullptr;
247 const uint8_t unused =
308 const uint16_t* name,
312 const uint32_t name_entries =
314 const uint32_t sec_count = 1U + name_entries;
316 for (uint32_t i = 0U; i < total; i++) {
333 for (uint32_t n = 0U; n < name_entries; n++) {
467 const char* leaf =
nullptr;
491 const uint32_t need =
499 uint32_t newclus = 0U;
500 uint64_t bmp_lba = 0U;
623 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_no_mem
Static buffer exhausted (no dynamic memory on this project).
@ k_ra8_err_not_empty
Container still holds members – the operation requires it empty.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_err_exists
Item already exists – cannot create again.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ 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.
uint64_t priv_cluster_to_lba(const ra8_fs_mount_t *m, uint32_t cluster)
Convert a cluster number into its first data-region LBA.
ra8_err_t priv_read_sector(const ra8_fs_mount_t *m, uint64_t lba, uint8_t *buf)
Read a single sector into the module scratch buffer.
uint32_t priv_bps(const ra8_fs_mount_t *m)
One mounted volume's sector size in bytes.
void priv_wr32(uint8_t *p, uint32_t v)
Encode a little-endian uint32_t into 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_write_sector(const ra8_fs_mount_t *m, uint64_t lba, const uint8_t *buf)
Write a single sector from a caller-provided buffer.
void priv_wr16(uint8_t *p, uint16_t v)
Encode a little-endian uint16_t into a byte buffer.
void priv_alloc_hint_set(const ra8_fs_mount_t *m, uint32_t cluster)
Move the next-free hint forward to cluster.
uint8_t * priv_sec_io(void)
The IO-role sector buffer (leaf data / bitmap sector transfers).
const uint8_t k_zero_sector[k_ra8_fs_sector_max]
One whole sector of zero bytes, in read-only storage.
ra8_err_t priv_exfat_mkdir(const ra8_fs_mount_t *m, const char *path)
Create one exFAT directory at path.
ra8_err_t priv_exfat_seal_cluster(const ra8_fs_mount_t *m, uint32_t clus)
Replace every end-of-directory marker in a cluster with an unused one.
ra8_err_t priv_exfat_rmdir(const ra8_fs_mount_t *m, const char *path)
Remove one EMPTY exFAT directory at path.
static ra8_err_t internal_exfat_mkdir_check(const ra8_fs_mount_t *m, const exfat_dir_t *parent, const char *leaf, uint32_t nlen)
Decide whether leaf may be created in parent.
static ra8_err_t internal_exfat_dir_alloc(const ra8_fs_mount_t *m, uint32_t *out_clus, uint64_t *out_bmp)
Allocate and initialise one cluster as an empty exFAT directory.
ra8_err_t priv_exfat_zero_cluster(const ra8_fs_mount_t *m, uint32_t clus)
Zero every sector of one cluster.
static ra8_err_t internal_exfat_dir_is_empty(const ra8_fs_mount_t *m, const exfat_dir_t *dir, uint8_t *out_empty)
Decide whether an exFAT directory holds any live entry.
static ra8_err_t internal_exfat_enter(const ra8_fs_mount_t *m, const exfat_dir_t *cur, const char *comp, uint32_t len, exfat_dir_t *out)
Descend into the named directory component within cur.
ra8_err_t priv_exfat_resolve_dir(const ra8_fs_mount_t *m, const char *path, exfat_dir_t *out)
Resolve a whole path to the directory it names.
ra8_err_t priv_exfat_lookup(const ra8_fs_mount_t *m, const char *path, uint8_t *out_strm, uint8_t *out_attr)
Resolve a path and return the leaf entry set's location fields.
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.
static uint32_t internal_exfat_build_dir_set(const ra8_fs_mount_t *m, uint8_t *set, const uint16_t *name, uint32_t nlen, uint32_t first)
Build the File + Stream + Name entry set a DIRECTORY needs.
static ra8_err_t internal_exfat_rmdir_locate(const ra8_fs_mount_t *m, const char *path, exfat_setpos_t *pos, uint32_t *out_count, uint8_t *strm, exfat_dir_t *out_dir)
Resolve a path to a removable exFAT directory's entry set.
ra8_err_t priv_exfat_drop_set(const ra8_fs_mount_t *m, const exfat_setpos_t *pos, uint32_t count)
Retire an entry set by clearing the in-use bit on every entry.
ra8_err_t priv_exfat_find_dir_space(const ra8_fs_mount_t *m, const exfat_dir_t *dir, uint32_t need, uint32_t *out_clus, uint32_t *out_idx)
Find need consecutive free entry slots inside one directory cluster.
void priv_exfat_dir_root(const ra8_fs_mount_t *m, exfat_dir_t *out)
Fill out with the volume root's directory location.
void priv_exfat_cursor_init(const exfat_dir_t *dir, exfat_cursor_t *out)
Aim a fresh cursor at the start of dir.
ra8_err_t priv_exfat_bitmap_clear(const ra8_fs_mount_t *m, uint64_t bmp_lba, uint32_t clus, uint32_t count)
Clear a contiguous cluster run in the allocation bitmap.
void priv_exfat_dir_from_set(const ra8_fs_mount_t *m, const uint8_t *strm, exfat_dir_t *out)
Build a directory location from a Stream entry's allocation fields.
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.
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_next_entry(const ra8_fs_mount_t *m, exfat_cursor_t *cur, uint8_t *out)
Fetch the next 32-byte directory entry, following the cluster chain.
uint32_t priv_strlen(const char *s)
Length of a NUL-terminated string.
ra8_err_t priv_exfat_find(const ra8_fs_mount_t *m, const exfat_dir_t *dir, const char *path, uint8_t *out_strm, uint8_t *out_attr)
Find a name in ONE exFAT directory.
ra8_err_t priv_exfat_bitmap_mark(const ra8_fs_mount_t *m, uint64_t bmp_lba, uint32_t clus, uint32_t count)
Mark a contiguous cluster run as allocated in the bitmap.
ra8_err_t priv_exfat_bitmap_scan(const ra8_fs_mount_t *m, uint64_t bmp_lba, uint32_t need, uint32_t *out_clus)
Find a contiguous free run, starting from the mount's next-free hint.
uint16_t priv_exfat_set_checksum(const uint8_t *set, uint32_t bytes)
Compute the SetChecksum over a built directory entry set.
uint16_t priv_exfat_name_hash(const uint16_t *name, uint32_t nlen)
Compute the exFAT NameHash for a name in UTF-16 code units.
ra8_err_t priv_exfat_write_dir_set(const ra8_fs_mount_t *m, uint32_t cluster, uint32_t idx, const uint8_t *set, uint32_t bytes)
Write a pre-built entry set into consecutive directory entries.
ra8_err_t priv_exfat_find_bitmap(const ra8_fs_mount_t *m, uint32_t *out_clus, uint32_t *out_len)
Locate the allocation-bitmap entry in the exFAT root directory.
Cross-TU shared declarations for the FAT/exFAT ra8_fs adapter.
void priv_exfat_file_stamp_create(uint8_t *file_entry)
Stamp a fresh exFAT File entry's create, modify, and access fields.
@ k_exfat_name_off
File-name entry character offset.
@ k_exfat_strm_off_dlen
Stream-ext DataLength (low 32 used).
@ k_exfat_strm_off_nlen
Stream-ext NameLength (UTF-16 units).
@ k_exfat_strm_off_clus
Stream-ext FirstCluster.
@ k_exfat_strm_off_flags
Stream-ext GeneralSecondaryFlags.
@ k_exfat_path_depth
Max nested components per exFAT path.
@ k_exfat_off_file_csum
File entry: SetChecksum (2 bytes).
@ k_exfat_name_per_entry
UTF-16 units per file-name entry.
@ k_exfat_entry_bytes
Directory entry size.
@ k_exfat_off_strm_valid
Stream entry: ValidDataLength (8 B).
@ k_exfat_off_strm_hash
Stream entry: NameHash (2 bytes).
@ k_exfat_entry_eod
End-of-directory marker.
@ k_exfat_secflag_alloc
AllocationPossible | NoFatChain.
@ k_exfat_entry_stream
Stream-extension entry.
@ k_exfat_off_file_attr
File entry: FileAttributes (2 bytes).
@ k_exfat_off_file_secnt
File entry: SecondaryCount.
@ k_exfat_name_u8_cap
That name in UTF-8: 3 * 64, plus a NUL.
@ k_exfat_max_set_bytes
(2 + ceil(64/15)) * 32 = 7 entries.
@ k_exfat_scan_limit
Max dir entries scanned (P10 bound).
@ k_exfat_attr_directory
FileAttributes: directory.
@ k_exfat_entry_name
File-name entry.
@ k_exfat_name_cap
Longest name we store, in UTF-16 units.
@ k_exfat_inuse_bit
Directory entry type bit 7 = in use.
@ k_exfat_entry_file
File directory entry.
@ k_exfat_set_max_entries
1 File + 1 Stream + 17 Name entries.
@ k_cluster_first_data
Cluster numbers start at 2.
Linear cursor over a directory's 32-byte entries.
uint32_t scanned
Total entries read (P10 bound).
Identifies the exFAT directory a lookup, scan or link operates in.
uint32_t self_cluster
Parent cluster holding this dir's File entry; 0 => root.
uint32_t self_index
File-entry index within self_cluster.
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.
Cached parse of one mounted FAT volume.
uint32_t sectors_per_cluster
BPB BPB_SecPerClus.