ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
fw_if_fs_posix_internal.h
Go to the documentation of this file.
1
15
16#pragma once
17
18#ifndef RA8_OFF_TARGET
19#error "port/posix is host-only and must never be compiled or linked into target firmware."
20#endif
21
22#include <stddef.h>
23#include <stdint.h>
24#include <time.h>
25
26#include "fw_if_fs.h"
27#include "fw_if_fs_posix.h"
28#include "ra8_attributes.h"
29#include "ra8_err.h"
30
40
70
79
81typedef enum : uint32_t {
86
92
99
107
109typedef struct {
110 const char* name;
111 uint16_t name_bytes;
112 uint16_t record_bytes;
114
121
127
129typedef struct {
131 int fd;
133
149
150#ifdef RA8_POSIX_TEST
152typedef int64_t (*fw_fs_posix_test_dir_read_fn_t)(void* ctx,
153 int fd,
154 uint8_t* buffer,
155 uint32_t capacity,
156 int* out_errno);
157
190ra8_fs_posix_test_set_directory_reader(fw_fs_posix_test_dir_read_fn_t reader, void* ctx);
191#endif
192
227
250
272
293 const char* target,
294 size_t target_bytes,
295 posix_root_alias_t* out_alias);
296
297#ifdef __APPLE__
321RA8_PRIV RA8_NODISCARD ra8_err_t priv_fs_posix_root_alias_verify(int parent_fd,
322 const char* component,
323 posix_root_alias_t* out_alias);
324#endif
325
353 posix_root_alias_t alias,
354 int* out_fd);
355
379 const char* component,
380 int* out_fd);
381
417 bool* out_end);
418
443RA8_PRIV RA8_NODISCARD fw_fs_timestamp_t priv_fs_posix_timestamp(time_t seconds, long nanoseconds);
444
468RA8_PRIV RA8_NODISCARD ra8_err_t priv_fs_posix_copy_path(char* out, const char* path);
469
499 uint32_t id,
500 char* out);
501
521 const char* path,
522 void* directory_state,
523 uint32_t state_bytes);
524
544 void* directory_state,
546 bool* out_entry);
547
564RA8_PRIV RA8_NODISCARD ra8_err_t priv_fs_posix_dir_close(void* ctx, void* directory_state);
565
588 const char* path,
589 uint32_t max_entries,
590 fw_fs_list_fn_t callback,
591 void* callback_ctx,
592 uint32_t* out_count,
593 bool* out_complete);
594
625 fw_fs_posix_state_t* state,
626 const fw_fs_caps_t* caps);
627
653 const char* path,
654 int* out_parent_fd,
655 char* out_leaf);
656
679 const char* path,
681 void* file_state,
682 uint32_t state_bytes);
683
705 void* file_state,
706 const uint8_t* src,
707 uint32_t len,
708 uint32_t* out_written);
709
728RA8_PRIV RA8_NODISCARD ra8_err_t priv_fs_posix_seek(void* ctx, void* file_state, uint64_t offset);
729
748 void* file_state,
749 uint64_t* out_size);
750
766RA8_PRIV RA8_NODISCARD ra8_err_t priv_fs_posix_sync(void* ctx, void* file_state);
767
784RA8_PRIV RA8_NODISCARD ra8_err_t priv_fs_posix_close(void* ctx, void* file_state);
785
Architecture-neutral filesystem namespace, stream, and transaction ports.
Root-confined hosted POSIX adapter for fw_if_fs.
ra8_err_t priv_fs_posix_stage_path(const char *destination, uint32_t id, char *out)
Build an 8.3-compatible sibling transaction path.
ra8_err_t priv_fs_posix_component_open(int parent_fd, const char *component, int *out_fd)
Open one validated directory component without following its pathname.
posix_root_alias_t
Classification of a verified filesystem-root directory alias.
@ k_posix_root_alias_tmp
Root tmp resolves to private/tmp.
@ k_posix_root_alias_none
Component is not an approved root alias.
@ k_posix_root_alias_var
Root var resolves to private/var.
ra8_err_t priv_fs_posix_seek(void *ctx, void *file_state, uint64_t offset)
Seek a POSIX descriptor to an unsigned absolute offset.
ra8_err_t priv_fs_posix_dir_open(void *ctx, const char *path, void *directory_state, uint32_t state_bytes)
Open a confined raw-directory cursor in caller storage.
ra8_err_t priv_fs_posix_close(void *ctx, void *file_state)
Close and consume one caller-owned POSIX file state.
ra8_err_t priv_fs_posix_sync(void *ctx, void *file_state)
Flush file contents and metadata through POSIX fsync.
ra8_err_t priv_fs_posix_write(void *ctx, void *file_state, const uint8_t *src, uint32_t len, uint32_t *out_written)
Complete POSIX short writes while reporting any accepted prefix.
ra8_err_t priv_fs_posix_dir_next(void *ctx, void *directory_state, fw_fs_dirent_value_t *out, bool *out_entry)
Copy the next visible raw-directory entry.
ra8_err_t priv_fs_posix_dir_close(void *ctx, void *directory_state)
Close one owned raw-directory descriptor.
ra8_err_t priv_fs_posix_close_fd(int *fd)
Close exactly once and invalidate the caller's descriptor.
ra8_err_t priv_fs_posix_bind_interfaces(fw_fs_t *out, fw_fs_posix_state_t *state, const fw_fs_caps_t *caps)
Bind the immutable POSIX operation tables to initialized state.
ra8_err_t priv_fs_posix_close_fd_preserve(int *fd, ra8_err_t primary)
Close one owned descriptor while preserving a primary status.
posix_numeric_limits_t
POSIX timestamp and transaction arithmetic constants.
@ k_posix_transaction_id_mask
Six hexadecimal digits.
@ k_posix_nanosecond_max
Largest valid subsecond.
@ k_posix_epoch_year_offset
struct tm year origin.
ra8_err_t priv_fs_posix_root_alias_classify(const char *component, const char *target, size_t target_bytes, posix_root_alias_t *out_alias)
Classify one exact filesystem-root alias component and target pair.
ra8_err_t priv_fs_posix_parent_open(fw_fs_posix_state_t *state, const char *path, int *out_parent_fd, char *out_leaf)
Resolve a canonical path's parent without following any symlink.
ra8_err_t priv_fs_posix_root_alias_open(int root_fd, posix_root_alias_t alias, int *out_fd)
Open a classified root alias through its canonical components.
ra8_err_t priv_fs_posix_size(void *ctx, void *file_state, uint64_t *out_size)
Report a POSIX descriptor's current file length.
ra8_err_t priv_fs_posix_directory_next(int fd, posix_directory_reader_t *reader, posix_directory_record_t *out, bool *out_end)
Read and validate the next raw hosted directory record.
posix_directory_limits_t
Raw directory buffer and retry bounds.
@ k_posix_directory_read_retries
Maximum interrupted reads.
@ k_posix_directory_buffer_bytes
Fixed local kernel buffer.
posix_limits_t
Local component and stage-search bounds.
@ k_posix_max_open_files
Truthful hosted descriptor capacity.
@ k_posix_file_mode
Owner-only created-file mode.
@ k_posix_stage_leaf_span
Stage leaf plus terminating NUL.
@ k_posix_directory_mode
Owner-only created-directory mode.
@ k_posix_stage_attempts
Collision-search attempt cap.
@ k_posix_component_cap
Component buffer including NUL.
ra8_err_t priv_fs_posix_copy_path(char *out, const char *path)
Copy one bounded portable path.
posix_linux_dirent_layout_t
Linux getdents64 wire-record offsets and alignment.
@ k_posix_linux_name_offset
Offset of d_name.
@ k_posix_linux_reclen_offset
Offset of d_reclen.
@ k_posix_linux_record_align
Kernel record alignment.
const fw_fs_stream_iface_t * priv_fs_posix_stream_iface(void)
Borrow the immutable POSIX byte-stream operation table.
posix_hex_limits_t
Hexadecimal stage-name encoding constants.
@ k_posix_hex_nibble_mask
Low-nibble mask.
@ k_posix_hex_last_digit
Highest valid index in a stage identifier.
@ k_posix_stage_hex_digits
Hex digits in a stage identifier.
@ k_posix_hex_nibble_bits
Bits represented by one hex digit.
ra8_err_t priv_fs_posix_errno(int value)
Map one captured errno value into ra8_err_t.
ra8_err_t priv_fs_posix_open(void *ctx, const char *path, fw_fs_open_mode_t mode, void *file_state, uint32_t state_bytes)
Open one confined regular file into caller workspace.
ra8_err_t priv_fs_posix_listdir(void *ctx, const char *path, uint32_t max_entries, fw_fs_list_fn_t callback, void *callback_ctx, uint32_t *out_count, bool *out_complete)
Enumerate a POSIX directory through bounded raw records.
posix_darwin_dirent_layout_t
Darwin getdirentries64 wire-record offsets and alignment.
@ k_posix_darwin_name_offset
Offset of d_name.
@ k_posix_darwin_record_align
Kernel record alignment.
@ k_posix_darwin_reclen_offset
Offset of d_reclen.
@ k_posix_darwin_namlen_offset
Offset of d_namlen.
fw_fs_timestamp_t priv_fs_posix_timestamp(time_t seconds, long nanoseconds)
Convert a POSIX UTC instant into the portable civil representation.
struct fw_fs_stream_iface fw_fs_stream_iface_t
@ k_fw_fs_path_cap
Largest portable path including its NUL.
fw_fs_open_mode_t
Open intent for fw_fs_open.
ra8_err_t(* fw_fs_list_fn_t)(void *ctx, const fw_fs_dirent_t *entry, bool *out_continue)
Bounded list callback.
fw_fs_transaction_policy_t
Destination policy for a staged transaction.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_PRIV
Module-private helper: shared across TUs but only inside one library.
#define RA8_TEST_HELPER
Mark a symbol as externally-linked but only callable from tests.
#define RA8_NODISCARD
Warn at any call site that discards the function's return value.
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
Static properties and workspace requirements of one bound port.
Stable caller-owned value returned by fw_fs_dir_next.
Caller-owned POSIX adapter state.
One complete composition-root filesystem binding.
One portable timestamp and independent availability facts.
Caller-owned cursor and fixed storage for raw directory batches.
uint8_t buffer[k_posix_directory_buffer_bytes]
Kernel record bytes.
uint32_t valid_bytes
Bytes in buffer.
uint32_t cursor
Next record offset.
Validated view over one raw host directory record.
uint16_t name_bytes
Name length excluding the terminator.
const char * name
NUL-terminated name inside the read buffer.
uint16_t record_bytes
Complete aligned record length.
POSIX state placed in caller directory workspace.
posix_directory_reader_t reader
Bounded raw-record buffer and cursor.
int fd
Owned directory descriptor.
POSIX state placed in caller file workspace.
int fd
Owned descriptor, or -1 while closed.
POSIX state placed in caller transaction workspace.
bool writer_open
True while the stage descriptor is owned.
fw_fs_transaction_policy_t policy
Requested destination collision policy.
char stage[k_fw_fs_path_cap]
Private sibling stage path.
char destination[k_fw_fs_path_cap]
Final publication path.
bool stage_exists
True while the stage leaf needs cleanup.
posix_file_state_t file_state
Open descriptor state for the stage.