ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_fs.h
Go to the documentation of this file.
1
128
129#pragma once
130
131#ifdef __cplusplus
132extern "C" {
133#endif
134
135#include <stdint.h>
136
137#include "ra8_err.h"
138#include "ra8_fs_seams.h"
139#include "ra8_fs_types.h"
140
141/* =============================================================================
142 * Public API -- format (mkfs)
143 * =============================================================================
144 */
145
237[[nodiscard]] ra8_err_t ra8_fs_format(const ra8_fs_backend_t* backend,
238 const ra8_fs_format_opts_t* opts);
239
263[[nodiscard]] ra8_err_t ra8_fs_probe(const ra8_fs_backend_t* backend, ra8_fs_type_t* out_type);
264
265/* =============================================================================
266 * Public API -- mount / unmount
267 * =============================================================================
268 */
269
303[[nodiscard]] ra8_err_t ra8_fs_mount(const ra8_fs_backend_t* backend, ra8_fs_mount_t** out_handle);
304
347[[nodiscard]] ra8_err_t
348ra8_fs_mount_partition(const ra8_fs_backend_t* backend, uint8_t index, ra8_fs_mount_t** out_handle);
349
372[[nodiscard]] ra8_err_t ra8_fs_unmount(ra8_fs_mount_t* handle);
373
374/* =============================================================================
375 * Public API -- file ops
376 * =============================================================================
377 */
378
436[[nodiscard]] ra8_err_t
437ra8_fs_open(ra8_fs_mount_t* handle, const char* path, ra8_fs_mode_t mode, ra8_fs_file_t** out_file);
438
460[[nodiscard]] ra8_err_t ra8_fs_close(ra8_fs_file_t* file);
461
475[[nodiscard]] ra8_err_t
476ra8_fs_read(ra8_fs_file_t* file, uint8_t* buf, uint32_t max_len, uint32_t* got_len);
477
497[[nodiscard]] ra8_err_t ra8_fs_write(ra8_fs_file_t* file, const uint8_t* buf, uint32_t len);
498
536[[nodiscard]] ra8_err_t
537ra8_fs_write_file(ra8_fs_mount_t* handle, const char* path, const uint8_t* data, uint32_t len);
538
546[[nodiscard]] ra8_err_t ra8_fs_seek(ra8_fs_file_t* file, uint64_t offset_bytes);
547
549[[nodiscard]] ra8_err_t ra8_fs_tell(const ra8_fs_file_t* file, uint64_t* out_offset);
550
552[[nodiscard]] ra8_err_t ra8_fs_size(const ra8_fs_file_t* file, uint64_t* out_bytes);
553
554/* =============================================================================
555 * Public API -- metadata
556 * =============================================================================
557 */
558
615[[nodiscard]] ra8_err_t
616ra8_fs_stat(const ra8_fs_mount_t* handle, const char* path, ra8_fs_stat_t* out);
617
618/* =============================================================================
619 * Public API -- directory ops
620 * =============================================================================
621 */
622
643[[nodiscard]] ra8_err_t
644ra8_fs_listdir(const ra8_fs_mount_t* handle, const char* path, ra8_fs_listdir_cb_t cb, void* ctx);
645
663[[nodiscard]] ra8_err_t
664ra8_fs_dir_open(ra8_fs_mount_t* handle, const char* path, ra8_fs_dir_t* directory);
665
676[[nodiscard]] ra8_err_t
677ra8_fs_dir_next(ra8_fs_dir_t* directory, ra8_fs_dirent_t* out, bool* out_entry);
678
686[[nodiscard]] ra8_err_t ra8_fs_dir_close(ra8_fs_dir_t* directory);
687
719[[nodiscard]] ra8_err_t ra8_fs_unlink(const ra8_fs_mount_t* handle, const char* path);
720
760[[nodiscard]] ra8_err_t
761ra8_fs_rename(const ra8_fs_mount_t* handle, const char* old_path, const char* new_path);
762
805[[nodiscard]] ra8_err_t ra8_fs_mkdir(const ra8_fs_mount_t* handle, const char* path);
806
862[[nodiscard]] ra8_err_t ra8_fs_rmdir(const ra8_fs_mount_t* handle, const char* path);
863
864#ifdef __cplusplus
865}
866#endif
Error Code Definitions for ra8-firmware.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
ra8_err_t ra8_fs_format(const ra8_fs_backend_t *backend, const ra8_fs_format_opts_t *opts)
Format a block device as a fresh, empty FAT12/FAT16/FAT32/exFAT volume.
ra8_err_t ra8_fs_listdir(const ra8_fs_mount_t *handle, const char *path, ra8_fs_listdir_cb_t cb, void *ctx)
Enumerate directory entries; invoke cb once per visible entry.
ra8_err_t ra8_fs_dir_next(ra8_fs_dir_t *directory, ra8_fs_dirent_t *out, bool *out_entry)
Copy the next visible directory entry.
ra8_err_t ra8_fs_rename(const ra8_fs_mount_t *handle, const char *old_path, const char *new_path)
Rename a file within its own directory.
ra8_err_t ra8_fs_write(ra8_fs_file_t *file, const uint8_t *buf, uint32_t len)
Write len bytes; allocate new clusters from FAT free-space scan as needed.
ra8_err_t ra8_fs_mount(const ra8_fs_backend_t *backend, ra8_fs_mount_t **out_handle)
Mount a FAT volume from a block-device backend, auto-selecting the first partition.
ra8_err_t ra8_fs_size(const ra8_fs_file_t *file, uint64_t *out_bytes)
Report the file's size in bytes (64-bit on exFAT, #676).
ra8_err_t ra8_fs_read(ra8_fs_file_t *file, uint8_t *buf, uint32_t max_len, uint32_t *got_len)
Read up to max_len bytes; advance the cluster chain on cluster crossings.
ra8_err_t ra8_fs_mount_partition(const ra8_fs_backend_t *backend, uint8_t index, ra8_fs_mount_t **out_handle)
Mount a FAT/exFAT volume from a specific partition of a block device.
ra8_err_t ra8_fs_stat(const ra8_fs_mount_t *handle, const char *path, ra8_fs_stat_t *out)
Report what a path names – file or directory – without opening it.
ra8_err_t ra8_fs_unlink(const ra8_fs_mount_t *handle, const char *path)
Delete a file: mark its dir entry deleted and free its clusters.
ra8_err_t ra8_fs_open(ra8_fs_mount_t *handle, const char *path, ra8_fs_mode_t mode, ra8_fs_file_t **out_file)
Open or create a file by path, 8.3 or long.
ra8_err_t ra8_fs_unmount(ra8_fs_mount_t *handle)
Unmount a previously mounted volume and release its slot.
ra8_err_t ra8_fs_mkdir(const ra8_fs_mount_t *handle, const char *path)
Create a directory at path.
ra8_err_t ra8_fs_rmdir(const ra8_fs_mount_t *handle, const char *path)
Remove an empty directory at path.
ra8_err_t ra8_fs_probe(const ra8_fs_backend_t *backend, ra8_fs_type_t *out_type)
Identify a FAT/exFAT volume without claiming a mount slot.
ra8_err_t ra8_fs_close(ra8_fs_file_t *file)
Close an open file, stamping its final modification time.
ra8_err_t ra8_fs_seek(ra8_fs_file_t *file, uint64_t offset_bytes)
Move the file offset to offset_bytes (clamped to size).
ra8_err_t ra8_fs_tell(const ra8_fs_file_t *file, uint64_t *out_offset)
Report the current offset (64-bit; see ra8_fs_seek).
ra8_err_t ra8_fs_write_file(ra8_fs_mount_t *handle, const char *path, const uint8_t *data, uint32_t len)
Create a whole file in one call (provisioning helper).
ra8_err_t ra8_fs_dir_close(ra8_fs_dir_t *directory)
Consume one open directory cursor.
ra8_err_t ra8_fs_dir_open(ra8_fs_mount_t *handle, const char *path, ra8_fs_dir_t *directory)
Open a caller-owned directory cursor without holding the filesystem lock.
The two dependency-injection seams ra8_fs offers its callers.
On-disk and handle data types shared by the ra8_fs public API.
ra8_fs_type_t
FAT variant detected from the BPB cluster-count rule.
ra8_fs_mode_t
File-open modes accepted by ra8_fs_open().
void(* ra8_fs_listdir_cb_t)(const char *name, uint8_t attr, uint64_t size, void *ctx)
Callback invoked once per directory entry by ra8_fs_listdir().
Block-device interface that ra8_fs runs on top of.
Caller-owned opaque directory cursor.
Stable directory-entry value copied by ra8_fs_dir_next.
Open-file state.
Tunables for ra8_fs_format() (the on-disk geometry of a fresh volume).
Cached parse of one mounted FAT volume.
What ra8_fs_stat() read out of a directory entry.