ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
mdl_pathfs.c
Go to the documentation of this file.
1
9#include "mdl_pathfs.h"
10
11#include <stdint.h>
12
13#include "mdl_sanitize.h"
14
16 const char* parent_abs,
17 const char* seg,
18 char* out,
19 size_t cap)
20{
21 if ((storage == nullptr) || (storage->fs == nullptr)) {
22 return false;
23 }
24 if (!mdl_path_join(parent_abs, seg, out, cap)) {
25 return false;
26 }
27 fw_fs_stat_t parent = {};
28 if ((fw_fs_stat(&storage->fs->names, parent_abs, &parent) != k_ra8_ok) || !parent.exists ||
29 (parent.type != k_fw_fs_node_directory)) {
30 return false;
31 }
32 const ra8_err_t made = fw_fs_mkdir(&storage->fs->names, out);
33 if ((made != k_ra8_ok) && (made != k_ra8_err_exists)) {
34 return false;
35 }
36 fw_fs_stat_t child = {};
37 return (fw_fs_stat(&storage->fs->names, out, &child) == k_ra8_ok) && child.exists &&
39}
ra8_err_t fw_fs_stat(const fw_fs_namespace_t *names, const char *path, fw_fs_stat_t *out)
Query a path; a miss is success with out->exists == false.
Definition fw_if_fs.c:480
ra8_err_t fw_fs_mkdir(const fw_fs_namespace_t *names, const char *path)
Create exactly one directory; parents must already exist.
Definition fw_if_fs.c:566
@ k_fw_fs_node_directory
Directory.
bool mdl_join_dir_under(mdl_storage_t *storage, const char *parent_abs, const char *seg, char *out, size_t cap)
Join seg under parent_abs, create it, and verify it stays inside.
Definition mdl_pathfs.c:15
Guarded filesystem directory joins for the media downloader.
Neutralise untrusted names before they reach a filesystem or XML sink.
bool mdl_path_join(const char *parent, const char *seg, char *out, size_t cap)
Join one safe child segment under a parent directory path.
@ k_ra8_err_exists
Item already exists – cannot create again.
Definition ra8_err.h:216
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
Definition ra8_err.h:119
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
Result of a portable metadata query.
bool exists
False means a clean lookup miss.
fw_fs_node_type_t type
Kind of node at the path.
fw_fs_namespace_t names
Namespace operations.
One non-reentrant downloader filesystem dependency bundle.
Definition mdl_storage.h:40
const fw_fs_t * fs
Injected portable filesystem.
Definition mdl_storage.h:41