ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
fw_if_fs_posix_contracts_internal.h
Go to the documentation of this file.
1
17#pragma once
18
19#ifndef RA8_OFF_TARGET
20#error "port/posix is host-only and must never be compiled or linked into target firmware."
21#endif
22
23#include <sys/stat.h>
24
26#include "ra8_attributes.h"
27
45static ra8_err_t internal_component_copy(const char* start, uint16_t length, char* out);
46
69static ra8_err_t
70internal_intermediate_check(int parent_fd, const char* component, posix_root_alias_t* out_alias);
71
91static ra8_err_t internal_next_component(const char** cursor, char* out_name, uint16_t* out_length);
92
112static ra8_err_t internal_parent_open_step(int* current, const char* name);
113
132
152 const char* path,
153 struct stat* out,
154 bool* out_exists);
155
173static ra8_err_t internal_stat(void* ctx, const char* path, fw_fs_stat_t* out);
174
194static ra8_err_t internal_directory_open(fw_fs_posix_state_t* state, const char* path, int* out_fd);
195
212static ra8_err_t internal_mkdir(void* ctx, const char* path);
213
233static ra8_err_t internal_unlink(void* ctx, const char* path);
234
254static ra8_err_t internal_rmdir(void* ctx, const char* path);
255
275static ra8_err_t
276internal_rename_noreplace(int old_fd, const char* old_leaf, int new_fd, const char* new_leaf);
277
299 const char* old_path,
300 const char* new_path);
301
324static ra8_err_t
325internal_rename(void* ctx, const char* old_path, const char* new_path, bool replace);
326
343static ra8_err_t internal_space(void* ctx, fw_fs_space_t* out);
344
363
389 void* transaction_state,
390 uint32_t state_bytes,
391 const char* destination,
393
415 void* transaction_state,
416 const uint8_t* src,
417 uint32_t len,
418 uint32_t* out_written);
419
439static ra8_err_t internal_txn_seek(void* ctx, void* transaction_state, uint64_t offset);
440
461 void* transaction_state,
462 fw_fs_validate_fn_t validator,
463 void* validator_ctx);
464
481static ra8_err_t internal_parent_sync(fw_fs_posix_state_t* state, const char* path);
482
501static ra8_err_t internal_txn_commit(void* ctx, void* transaction_state, bool* out_published);
502
519static ra8_err_t internal_txn_abort(void* ctx, void* transaction_state);
static ra8_err_t internal_intermediate_check(int parent_fd, const char *component, posix_root_alias_t *out_alias)
Validate one directory component without following a symbolic link.
static ra8_err_t internal_directory_open(fw_fs_posix_state_t *state, const char *path, int *out_fd)
Open a confined directory without following its final component.
static ra8_err_t internal_txn_commit(void *ctx, void *transaction_state, bool *out_published)
Atomically publish then durably sync the destination directory.
static ra8_err_t internal_component_copy(const char *start, uint16_t length, char *out)
Copy one bounded path component into a fixed local buffer.
static ra8_err_t internal_parent_open_step(int *current, const char *name)
Descend into one intermediate path component, retiring the old parent.
static ra8_err_t internal_txn_begin(void *ctx, void *transaction_state, uint32_t state_bytes, const char *destination, fw_fs_transaction_policy_t policy)
Begin a staged POSIX create-new or atomic-replacement transaction.
static ra8_err_t internal_stage_open(fw_fs_posix_state_t *state, posix_transaction_state_t *txn)
Create an exclusive sibling stage after bounded collision retries.
static ra8_err_t internal_rename(void *ctx, const char *old_path, const char *new_path, bool replace)
Rename within the selected root without following either leaf.
static fw_fs_node_type_t internal_node_type(mode_t mode)
Convert a POSIX mode into a portable node kind.
static ra8_err_t internal_space(void *ctx, fw_fs_space_t *out)
Query confined-root volume byte totals with fstatvfs.
static ra8_err_t internal_txn_validate(void *ctx, void *transaction_state, fw_fs_validate_fn_t validator, void *validator_ctx)
Durably sync, reopen read-only, and validate a POSIX stage.
static ra8_err_t internal_rename_validate_endpoints(fw_fs_posix_state_t *state, const char *old_path, const char *new_path)
Validate that a rename's source exists and neither endpoint is a symlink.
static ra8_err_t internal_next_component(const char **cursor, char *out_name, uint16_t *out_length)
Scan and copy the next slash-delimited component of a cursor.
static ra8_err_t internal_parent_sync(fw_fs_posix_state_t *state, const char *path)
Sync the destination's containing directory after publication.
static ra8_err_t internal_mkdir(void *ctx, const char *path)
Create one confined directory with no implicit parent creation.
static ra8_err_t internal_native_stat(fw_fs_posix_state_t *state, const char *path, struct stat *out, bool *out_exists)
Query native metadata without following the final component.
static ra8_err_t internal_txn_abort(void *ctx, void *transaction_state)
Close and remove a POSIX stage while preserving the destination.
static ra8_err_t internal_txn_seek(void *ctx, void *transaction_state, uint64_t offset)
Seek within the open POSIX stage for bounded header or table backfill.
static ra8_err_t internal_rmdir(void *ctx, const char *path)
Remove one confined empty real directory.
static ra8_err_t internal_txn_write(void *ctx, void *transaction_state, const uint8_t *src, uint32_t len, uint32_t *out_written)
Append bytes to an open POSIX transaction stage.
static ra8_err_t internal_rename_noreplace(int old_fd, const char *old_leaf, int new_fd, const char *new_leaf)
Perform a host atomic no-replace rename without a TOCTOU fallback.
static ra8_err_t internal_unlink(void *ctx, const char *path)
Remove one confined regular file while refusing directories and links.
static ra8_err_t internal_stat(void *ctx, const char *path, fw_fs_stat_t *out)
Produce portable metadata for one path below the confined root.
Shared errno/descriptor helpers for the POSIX filesystem port.
posix_root_alias_t
Classification of a verified filesystem-root directory alias.
fw_fs_node_type_t
Filesystem node kind reported by fw_fs_stat.
ra8_err_t(* fw_fs_validate_fn_t)(void *ctx, fw_fs_file_t *staged)
Validate staged bytes through a read-only generic file handle.
fw_fs_transaction_policy_t
Destination policy for a staged transaction.
Annotation-attribute framework macros 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
Caller-owned POSIX adapter state.
Portable volume usage snapshot.
Result of a portable metadata query.
POSIX state placed in caller transaction workspace.