99 {
'N',
'O',
' ',
'N',
'A',
'M',
'E',
' ',
' ',
' ',
' '};
108 if (raw11[n - 1U] != (uint8_t)
' ') {
114 for (uint32_t i = 0U; i < n; i++) {
115 if ((w + 1U) >= out_len) {
118 out[w] = (char)raw11[i];
157 const dir_loc_t loc = {.is_root = 1U, .cluster = 0U};
224 const dir_loc_t loc = {.is_root = 1U, .cluster = 0U};
362 uint8_t* e = &sec[off];
455 const bool clearing = (label ==
nullptr) || (label[0] ==
'\0');
514 if (handle ==
nullptr || out ==
nullptr) {
520 if (handle->in_use == 0U) {
521 return k_ra8_err_invalid_state;
525 return priv_exfat_get_label(handle, out, out_len);
564 if (handle ==
nullptr) {
567 if (handle->in_use == 0U) {
568 return k_ra8_err_invalid_state;
574 return priv_exfat_set_label(handle, label);
Annotation-attribute framework macros for ra8-firmware.
#define RA8_OWNS_RESOURCE(kind)
RAII-style resource ownership contract.
#define RA8_EXPECTS_LOCK(name)
The function expects the named thread/IRQ lock to be held on entry.
#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_invalid_arg
Invalid function argument.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_null_ptr
Pointer was NULL where a valid pointer was required.
@ 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_dir_eps(const ra8_fs_mount_t *m)
Directory entries per sector on one mounted volume.
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.
uint8_t priv_byte_equal(const uint8_t *a, const uint8_t *b, uint32_t n)
Compare two byte buffers for equality (length n).
void priv_byte_copy(uint8_t *dst, const uint8_t *src, uint32_t n)
Length-checked byte copy used in place of memcpy().
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.
uint8_t * priv_sec_walk(void)
The WALK-role sector buffer (directory scans and entry RMW).
uint32_t priv_strlen(const char *s)
Length of a NUL-terminated string.
void priv_fmt_label_field(uint8_t *dst, const char *label)
Pad an ASCII volume label into an 11-byte BS_VolLab / label field.
Cross-TU shared declarations for the FAT/exFAT ra8_fs adapter.
static ra8_err_t internal_fat_del_entry(const ra8_fs_mount_t *m, uint64_t lba, uint32_t off)
Mark the root directory entry at lba / off deleted.
static uint32_t internal_fat_boot_label_off(const ra8_fs_mount_t *m)
Byte offset of BS_VolLab in this volume's boot sector.
static ra8_err_t internal_get_label_fat(const ra8_fs_mount_t *m, char *out, uint32_t out_len)
Read a FAT volume's label – root ATTR_VOLUME_ID, else BS_VolLab.
static ra8_err_t internal_fat_find_free_root(const ra8_fs_mount_t *m, uint64_t *out_lba, uint32_t *out_off)
Find the first free slot in the root directory.
static ra8_err_t internal_fat_find_vol_id(const ra8_fs_mount_t *m, uint64_t *out_lba, uint32_t *out_off, uint8_t *out_entry)
Find the root directory's ATTR_VOLUME_ID entry.
static ra8_err_t internal_fat_boot_set_label(const ra8_fs_mount_t *m, const char *label)
Write the boot sector's BS_VolLab field.
static ra8_err_t internal_fat_put_vol_id(const ra8_fs_mount_t *m, uint64_t lba, uint32_t off, const char *label, bool fresh)
Write a root-directory ATTR_VOLUME_ID entry at lba / off.
static ra8_err_t internal_get_label_locked(const ra8_fs_mount_t *handle, char *out, uint32_t out_len)
Read the volume label – the guarded body of ra8_fs_get_label().
static ra8_err_t internal_set_label_fat(const ra8_fs_mount_t *m, const char *label)
Set a FAT volume's label – boot sector plus root entry, kept in step.
static ra8_err_t internal_set_label_locked(const ra8_fs_mount_t *handle, const char *label)
Set the volume label – the guarded body of ra8_fs_set_label().
static void internal_label_from_raw(const uint8_t *raw11, char *out, uint32_t out_len)
Decode an 11-byte packed FAT label into a trimmed ASCII string.
void priv_lock_release(void)
Drop the library lock taken by priv_lock_acquire.
void priv_lock_acquire(void)
Take the library lock, if the caller installed one.
void priv_dir_walk_init_loc(const ra8_fs_mount_t *m, const dir_loc_t *loc, dir_walk_t *w)
Initialise a directory walker for an arbitrary directory location.
ra8_err_t priv_dir_walk_next_sector(const ra8_fs_mount_t *m, dir_walk_t *w, uint8_t *out_eod)
Advance the walker to the next sector.
void priv_fat_entry_stamp_write(uint8_t *entry)
Advance a FAT directory entry's modification time and access date.
void priv_fat_entry_stamp_create(uint8_t *entry)
Stamp a fresh FAT directory entry's create, write, and access fields.
@ k_fmt_off_f32_label
FAT32 BS_VolLab (11 bytes).
@ k_fmt_off_f16_label
FAT12/16 BS_VolLab (11 bytes).
@ k_dir_off_attr
MS FAT spec sec 6 "DIR_Attr".
@ k_dir_off_name
MS FAT spec sec 6 "DIR_Name" (11 bytes).
@ k_fmt_label_len
Volume-label field width (bytes).
@ k_dir_marker_free_used
Slot was used, deleted.
@ k_dir_marker_free_perm
End-of-directory.
@ k_ra8_fs_type_fat32
count_of_clusters >= 65525.
@ k_ra8_fs_type_exfat
exFAT (read + streaming write + format).
@ k_ra8_fs_attr_lfn
Long-file-name marker (we skip).
@ k_ra8_fs_attr_volume_id
MS FAT spec sec 6 "ATTR_VOLUME_ID".
@ k_ra8_fs_dir_entry_bytes
MS FAT spec sec 6 "Directory Entry".
Identifies the directory a lookup/scan should operate in.
Internal cursor used by the directory iterator.
uint64_t cur_lba
Currently loaded LBA.
Cached parse of one mounted FAT volume.
ra8_fs_type_t type
FAT12 / FAT16 / FAT32.