ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_fs_file_t Struct Reference

Open-file state. More...

#include <ra8_fs_types.h>

Collaboration diagram for ra8_fs_file_t:

Data Fields

ra8_fs_mount_tmount
 Owning mount point.
uint32_t first_cluster
 Head of the file's cluster chain.
uint32_t cur_cluster
 Cluster the offset currently points into.
uint32_t walk_cache_idx
 Chain index whose cluster is cached below.
uint32_t walk_cache_cluster
 Cluster at walk_cache_idx; < 2 = no cache.
uint64_t size_bytes
 File size (DIR_FileSize / DataLength).
uint64_t offset
 Current read/write offset.
uint64_t dir_entry_lba
 FAT: sector containing the dir entry.
uint32_t dir_entry_idx
 FAT: byte offset of the entry in it.
uint64_t valid_bytes
 exFAT ValidDataLength (bytes written).
uint32_t entry_set_cluster
 exFAT: dir cluster of the File entry.
uint32_t entry_set_index
 exFAT: entry index of the File entry.
uint32_t entry_set_count
 exFAT: 1 + SecondaryCount.
uint32_t alloc_clusters
 exFAT: clusters currently allocated.
uint32_t tail_cluster
 exFAT: last cluster of the allocation.
ra8_fs_mode_t mode
 Open mode.
uint8_t in_use
 0 = slot free, 1 = open.
uint8_t no_fat_chain
 exFAT contiguous file (no FAT walk).
uint8_t dirty
 1 once written; drives the close mtime.

Detailed Description

Open-file state.

The first block is common to both filesystems. The entry_set_*, alloc_clusters, tail_cluster and valid_bytes fields carry the extra bookkeeping an exFAT stream needs and are meaningless on a FAT12/16/32 handle: exFAT locates a file by a directory ENTRY SET rather than one 32-byte entry, tracks its allocation separately from its length (the allocation bitmap, not a FAT chain, is authoritative), and distinguishes the bytes actually written (ValidDataLength) from the file's length (DataLength).

The three byte lengths are 64-bit because exFAT's on-disk DataLength / ValidDataLength are (#676): a file past 4 GiB is exactly what exFAT exists to carry. On FAT12/16/32 the same fields never exceed k_ra8_fs_fat_max_file_bytesDIR_FileSize is 32-bit – and the write and truncate paths enforce that cap rather than wrapping.

Invariant
valid_bytes <= size_bytes on an exFAT handle.
alloc_clusters * cluster_bytes >= size_bytes on an exFAT handle.
no_fat_chain != 0 implies the allocation is the contiguous run [first_cluster, first_cluster + alloc_clusters).
size_bytes <= k_ra8_fs_fat_max_file_bytes on a FAT handle.
See also
ra8_fs_open()
Since
0.1.0

Definition at line 304 of file ra8_fs_types.h.

Field Documentation

◆ alloc_clusters

uint32_t ra8_fs_file_t::alloc_clusters

exFAT: clusters currently allocated.

Definition at line 318 of file ra8_fs_types.h.

◆ cur_cluster

uint32_t ra8_fs_file_t::cur_cluster

Cluster the offset currently points into.

Definition at line 307 of file ra8_fs_types.h.

Referenced by internal_exfat_open_found(), internal_init_new_file(), internal_open_existing(), and internal_truncate_existing().

◆ dir_entry_idx

uint32_t ra8_fs_file_t::dir_entry_idx

FAT: byte offset of the entry in it.

Definition at line 313 of file ra8_fs_types.h.

Referenced by internal_init_new_file(), and internal_open_existing().

◆ dir_entry_lba

uint64_t ra8_fs_file_t::dir_entry_lba

FAT: sector containing the dir entry.

Definition at line 312 of file ra8_fs_types.h.

Referenced by internal_init_new_file(), and internal_open_existing().

◆ dirty

uint8_t ra8_fs_file_t::dirty

1 once written; drives the close mtime.

Definition at line 323 of file ra8_fs_types.h.

Referenced by internal_init_new_file(), and internal_open_existing().

◆ entry_set_cluster

uint32_t ra8_fs_file_t::entry_set_cluster

exFAT: dir cluster of the File entry.

Definition at line 315 of file ra8_fs_types.h.

◆ entry_set_count

uint32_t ra8_fs_file_t::entry_set_count

exFAT: 1 + SecondaryCount.

Definition at line 317 of file ra8_fs_types.h.

◆ entry_set_index

uint32_t ra8_fs_file_t::entry_set_index

exFAT: entry index of the File entry.

Definition at line 316 of file ra8_fs_types.h.

◆ first_cluster

uint32_t ra8_fs_file_t::first_cluster

Head of the file's cluster chain.

Definition at line 306 of file ra8_fs_types.h.

Referenced by internal_exfat_open_found(), internal_init_new_file(), internal_open_existing(), and internal_truncate_existing().

◆ in_use

uint8_t ra8_fs_file_t::in_use

0 = slot free, 1 = open.

Definition at line 321 of file ra8_fs_types.h.

Referenced by internal_exfat_open_created(), internal_exfat_open_found(), internal_init_new_file(), and internal_open_existing().

◆ mode

ra8_fs_mode_t ra8_fs_file_t::mode

Open mode.

Definition at line 320 of file ra8_fs_types.h.

Referenced by internal_init_new_file(), and internal_open_existing().

◆ mount

ra8_fs_mount_t* ra8_fs_file_t::mount

◆ no_fat_chain

uint8_t ra8_fs_file_t::no_fat_chain

exFAT contiguous file (no FAT walk).

Definition at line 322 of file ra8_fs_types.h.

Referenced by internal_exfat_open_found(), internal_init_new_file(), and internal_open_existing().

◆ offset

uint64_t ra8_fs_file_t::offset

Current read/write offset.

Definition at line 311 of file ra8_fs_types.h.

Referenced by internal_exfat_open_found(), internal_init_new_file(), internal_open_existing(), and internal_truncate_existing().

◆ size_bytes

uint64_t ra8_fs_file_t::size_bytes

File size (DIR_FileSize / DataLength).

Definition at line 310 of file ra8_fs_types.h.

Referenced by internal_exfat_open_found(), internal_init_new_file(), internal_open_existing(), and internal_truncate_existing().

◆ tail_cluster

uint32_t ra8_fs_file_t::tail_cluster

exFAT: last cluster of the allocation.

Definition at line 319 of file ra8_fs_types.h.

◆ valid_bytes

uint64_t ra8_fs_file_t::valid_bytes

exFAT ValidDataLength (bytes written).

Definition at line 314 of file ra8_fs_types.h.

Referenced by internal_exfat_open_found().

◆ walk_cache_cluster

uint32_t ra8_fs_file_t::walk_cache_cluster

Cluster at walk_cache_idx; < 2 = no cache.

Definition at line 309 of file ra8_fs_types.h.

Referenced by internal_exfat_open_found(), internal_init_new_file(), internal_open_existing(), and internal_truncate_existing().

◆ walk_cache_idx

uint32_t ra8_fs_file_t::walk_cache_idx

Chain index whose cluster is cached below.

Definition at line 308 of file ra8_fs_types.h.

Referenced by internal_init_new_file(), internal_open_existing(), and internal_truncate_existing().


The documentation for this struct was generated from the following file: