|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
exFAT volume-label read/write (the exFAT half of ra8_fs_{get,set}_label). More...
#include <stddef.h>#include <stdint.h>#include "ra8_attributes.h"#include "ra8_fs.h"#include "ra8_fs_fat_internal.h"#include "ra8_fs_meta.h"Go to the source code of this file.
Functions | |
| static ra8_err_t | internal_exfat_locate_label (const ra8_fs_mount_t *m, exfat_setpos_t *out_pos, uint8_t *out_entry, bool *out_present) |
| Locate the exFAT Volume Label entry (or the slot to create one at). | |
| static void | internal_exfat_label_decode (const uint8_t *entry, char *out, uint32_t out_len) |
| Decode an exFAT Volume Label entry's UTF-16LE label into ASCII. | |
| ra8_err_t | priv_exfat_get_label (const ra8_fs_mount_t *m, char *out, uint32_t out_len) |
| Read an exFAT volume's label into an ASCII buffer. | |
| ra8_err_t | priv_exfat_set_label (const ra8_fs_mount_t *m, const char *label) |
| Set (or clear) an exFAT volume's label in place. | |
exFAT volume-label read/write (the exFAT half of ra8_fs_{get,set}_label).
exFAT keeps the volume label in a single root-directory entry – the Volume Label entry, type 0x83 when a label is present, 0x03 (in-use bit clear) when it is not (exFAT spec sec 7.7). Unlike a File entry set, it stands alone with no secondary entries and no SetChecksum spanning several entries, so reading and rewriting it is a single-entry operation. The FAT half, and the public lock-bracketed entry points that dispatch here, live in ra8_fs_fat_label.c.
References (every shorthand citation in this file):
NASA Power-of-Ten compliance:
Definition in file ra8_fs_fat_exfat_label.c.
|
static |
Decode an exFAT Volume Label entry's UTF-16LE label into ASCII.
Reads the CharacterCount and copies the low byte of each UTF-16 code unit – the ASCII character for a Latin-1 label – into out, truncated to the entry's cap and to out_len, and NUL-terminated.
| [in] | entry | A 32-byte Volume Label entry (type 0x83). |
| [out] | out | Buffer receiving the NUL-terminated label. |
| [in] | out_len | Capacity of out in bytes (at least 1). |
entry and out are non-NULL; out_len >= 1. entry is an in-use Volume Label entry. out is NUL-terminated (possibly truncated). out[out_len-1] is written.Definition at line 123 of file ra8_fs_fat_exfat_label.c.
References k_exfat_de_lbl_cnt, k_exfat_de_lbl_name, and k_exfat_fmt_label_max.
Referenced by priv_exfat_get_label().
|
static |
Locate the exFAT Volume Label entry (or the slot to create one at).
Scans the root directory. On the first entry whose type – ignoring the in-use bit – is the Volume Label type (0x83 present, or 0x03 cleared), reports it: out_pos its position, out_entry its 32 bytes, out_present true. If end-of-directory is reached first the volume carries no label entry: out_pos is the EOD slot a new one would go in and out_present is false.
| [in] | m | Mounted exFAT volume. |
| [out] | out_pos | Position of the label entry, or of the EOD slot. |
| [out] | out_entry | The 32-byte label entry (only meaningful when present). |
| [out] | out_present | Receives true when a label entry exists. |
| k_ra8_ok | out_pos / out_present populated. |
| k_ra8_err_not_found | The scan limit was hit without an entry or EOD. |
| k_ra8_err_* | Backend read failure. |
out_pos addresses a writable root-directory slot. Definition at line 67 of file ra8_fs_fat_exfat_label.c.
References exfat_cursor_t::cluster, exfat_cursor_t::entry_in_cluster, k_exfat_entry_bytes, k_exfat_entry_eod, k_exfat_entry_label, k_exfat_inuse_bit, k_exfat_scan_limit, k_ra8_err_not_found, k_ra8_ok, priv_byte_copy(), priv_exfat_cursor_init(), priv_exfat_dir_root(), priv_exfat_next_entry(), and exfat_cursor_t::scanned.
Referenced by priv_exfat_get_label(), and priv_exfat_set_label().
| ra8_err_t priv_exfat_get_label | ( | const ra8_fs_mount_t * | m, |
| char * | out, | ||
| uint32_t | out_len ) |
Read an exFAT volume's label into an ASCII buffer.
Scans the root directory for the Volume Label directory entry (exFAT spec sec 7.7): an in-use entry (type 0x83) yields its UTF-16LE label decoded to ASCII (low byte of each code unit), truncated to out_len; a cleared entry (type 0x03) or no entry at all yields the empty string. The exFAT half of ra8_fs_get_label.
| [in] | m | Mounted exFAT volume. |
| [out] | out | Buffer receiving the NUL-terminated label. |
| [in] | out_len | Capacity of out in bytes (at least 1). |
| k_ra8_ok | out holds the label (possibly empty). |
| k_ra8_err_* | Backend read failure, or a volume with no directory. |
m and out are non-NULL; m->type is exFAT; out_len >= 1. out is NUL-terminated. Definition at line 141 of file ra8_fs_fat_exfat_label.c.
References internal_exfat_label_decode(), internal_exfat_locate_label(), k_exfat_entry_bytes, k_exfat_entry_label, and k_ra8_ok.
| ra8_err_t priv_exfat_set_label | ( | const ra8_fs_mount_t * | m, |
| const char * | label ) |
Set (or clear) an exFAT volume's label in place.
Rewrites the root Volume Label directory entry (exFAT spec sec 7.7) with the new UTF-16LE label and character count, creating one at the end-of-directory position when the volume carries none. A NULL or empty label writes a zero-length label entry (the unlabelled form). The exFAT half of ra8_fs_set_label.
| [in] | m | Mounted exFAT volume. |
| [in] | label | New label (<= 11 characters), or NULL / "" to clear it. |
| k_ra8_ok | Label written. |
| k_ra8_err_not_found | The root directory could not be scanned. |
| k_ra8_err_* | Backend read/write failure. |
m is non-NULL; m->type is exFAT; the mount is in use. label, when non-NULL, is at most 11 characters. label. Definition at line 159 of file ra8_fs_fat_exfat_label.c.
References exfat_setpos_t::cluster, exfat_setpos_t::index, internal_exfat_locate_label(), k_exfat_de_lbl_cnt, k_exfat_de_lbl_name, k_exfat_entry_bytes, k_exfat_entry_label, k_exfat_fmt_label_max, k_ra8_ok, and priv_exfat_write_dir_set().