rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
fm_io.h
Go to the documentation of this file.
1
24
25#pragma once
26
27#include <stdbool.h>
28#include <stddef.h>
29#include <stdint.h>
30
31#include "fm_name.h"
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
44#define FM_NAME_BUF (FM_LIST_NAME_MAX + 1u)
45
73
78typedef struct {
79 const char *name;
80 uint64_t size;
81 bool is_dir;
83
87typedef struct {
88 uint64_t size;
89 bool is_dir;
90 int64_t mtime;
92} fm_stat_t;
93
97typedef enum {
100} fm_mode_t;
101
107typedef void (*fm_visit_fn)(const fm_dirent_t *entry, void *vctx);
108
117typedef struct {
123 bool (*mounted)(void *ctx);
129 unsigned (*mounts)(void *ctx);
138 bool (*hold)(void *ctx, unsigned mount);
143 void (*release)(void *ctx);
167 fm_err_t (*walk)(void *ctx, const char *dir, fm_visit_fn visit,
168 void *vctx, unsigned *unlisted);
176 fm_err_t (*stat)(void *ctx, const char *path, fm_stat_t *out);
183 fm_err_t (*mkdir)(void *ctx, const char *path);
190 fm_err_t (*unlink)(void *ctx, const char *path);
198 fm_err_t (*rmdir)(void *ctx, const char *path);
210 fm_err_t (*rename)(void *ctx, const char *from, const char *to);
219 fm_err_t (*open)(void *ctx, const char *path, fm_mode_t mode,
220 void **file);
230 fm_err_t (*read)(void *ctx, void *file, uint8_t *buf, size_t cap,
231 size_t *got);
240 fm_err_t (*write)(void *ctx, void *file, const uint8_t *buf, size_t len);
247 fm_err_t (*sync)(void *ctx, void *file);
254 fm_err_t (*close)(void *ctx, void *file);
255 void *ctx;
256} fm_io_t;
257
258#ifdef __cplusplus
259}
260#endif
fm_err_t
What a call of the core or of the card came to. FM_OK is 0; every other value is a refusal or a failu...
Definition fm_io.h:51
@ FM_ERR_DENIED
Definition fm_io.h:58
@ FM_ERR_NOT_EMPTY
Definition fm_io.h:65
@ FM_ERR_EXISTS
Definition fm_io.h:56
@ FM_ERR_CARD_GONE
Definition fm_io.h:54
@ FM_ERR_FULL
Definition fm_io.h:57
@ FM_ERR_FIXED
Definition fm_io.h:60
@ FM_ERR_NO_CARD
Definition fm_io.h:53
@ FM_ERR_NOT_FOUND
Definition fm_io.h:55
@ FM_ERR_LOGGING
Definition fm_io.h:69
@ FM_ERR_ARG
Definition fm_io.h:63
@ FM_ERR_LOCKED
Definition fm_io.h:61
@ FM_ERR_TOO_BIG
Definition fm_io.h:67
@ FM_ERR_IO
Definition fm_io.h:64
@ FM_ERR_CANCELLED
Definition fm_io.h:70
@ FM_ERR_SAME
Definition fm_io.h:66
@ FM_ERR_ARMED
Definition fm_io.h:68
@ FM_ERR_BUSY
Definition fm_io.h:59
@ FM_ERR_NAME
Definition fm_io.h:62
fm_mode_t
How open() opens a file.
Definition fm_io.h:97
@ FM_OPEN_READ
Definition fm_io.h:98
@ FM_OPEN_NEW
Definition fm_io.h:99
void(*) fm_visit_fn(const fm_dirent_t *entry, void *vctx)
Called once per entry of a walk.
Definition fm_io.h:107
The file manager's names and paths: which name a person may give a file or a folder,...
One directory entry as a walk hands it over, borrowed for the call.
Definition fm_io.h:78
bool is_dir
Definition fm_io.h:81
uint64_t size
Definition fm_io.h:80
const char * name
Definition fm_io.h:79
The card: every function set, each answering FM_OK or the reason it failed. ctx is passed to each of ...
Definition fm_io.h:117
fm_err_t(*) read(void *ctx, void *file, uint8_t *buf, size_t cap, size_t *got)
Read up to cap bytes from the file's position on.
Definition fm_io.h:230
fm_err_t(*) unlink(void *ctx, const char *path)
Delete file path.
Definition fm_io.h:190
fm_err_t(*) rename(void *ctx, const char *from, const char *to)
Give from the path to, on the one volume: no data moves.
Definition fm_io.h:210
fm_err_t(*) close(void *ctx, void *file)
Close an open() handle.
Definition fm_io.h:254
fm_err_t(*) walk(void *ctx, const char *dir, fm_visit_fn visit, void *vctx, unsigned *unlisted)
Hand every entry of folder dir to visit, in the order the volume holds them.
Definition fm_io.h:167
fm_err_t(*) write(void *ctx, void *file, const uint8_t *buf, size_t len)
Write len bytes at the file's end, all of them or fail.
Definition fm_io.h:240
void * ctx
Definition fm_io.h:255
bool(*) mounted(void *ctx)
Whether a volume is mounted now.
Definition fm_io.h:123
void(*) release(void *ctx)
The end of a hold() that answered true.
Definition fm_io.h:143
fm_err_t(*) stat(void *ctx, const char *path, fm_stat_t *out)
The size and kind of one name.
Definition fm_io.h:176
bool(*) hold(void *ctx, unsigned mount)
Keep the volume of mount mount for the calls that follow, until release().
Definition fm_io.h:138
fm_err_t(*) mkdir(void *ctx, const char *path)
Make folder path, whose parent is there.
Definition fm_io.h:183
fm_err_t(*) sync(void *ctx, void *file)
Put what was written on the card: fflush() and fsync().
Definition fm_io.h:247
fm_err_t(*) open(void *ctx, const char *path, fm_mode_t mode, void **file)
Open file path.
Definition fm_io.h:219
fm_err_t(*) rmdir(void *ctx, const char *path)
Delete the empty folder path.
Definition fm_io.h:198
unsigned(*) mounts(void *ctx)
The mount number: another one after a card is put in.
Definition fm_io.h:129
What stat() reads of one name.
Definition fm_io.h:87
uint64_t size
Definition fm_io.h:88
int64_t mtime
Definition fm_io.h:90
bool is_dir
Definition fm_io.h:89