35#ifndef PROTOCORE_MNT_H
36#define PROTOCORE_MNT_H
89 int (*
open)(
const char *path,
int mode);
90 int (*
read)(
int handle,
void *buf,
size_t n);
91 int (*
write)(
int handle,
const void *buf,
size_t n);
94 long (*
size)(
const char *path);
123#define PROTOCORE_MNT_NONE 0xFFu
164 void (*
const point_add)(uint8_t *work);
165 void (*
const point_of)(uint8_t *work);
166 void (*
const root_of)(uint8_t *work);
167 void (*
const reset)(uint8_t *work);
168 void (*
const mount)(uint8_t *work);
169 void (*
const active)(uint8_t *work);
185static const MntNs Mnt __attribute__((unused)) = {
PROTO_ENUM_PACKED
Application protocol spoken on a listener port or connection slot.
void protocore_mnt_point_of(uint8_t *work)
void protocore_mnt_point_add(uint8_t *work)
void protocore_mnt_active(uint8_t *work)
MntVars MntV
The operands and the outcome.
void protocore_mnt_root_of(uint8_t *work)
void protocore_mnt_mount(uint8_t *work)
@ PROTOCORE_MNT_READ
Read existing file (fails if absent).
@ PROTOCORE_MNT_WRITE
Create/truncate for writing.
@ PROTOCORE_MNT_RDWR
Open existing for random read+write, no truncation (fails if absent).
@ PROTOCORE_MNT_APPEND
Create/open for appending at end.
PROTOCORE_BEGIN_DECLS enum PROTO_ENUM_PACKED protocore_mnt_mode
Open modes.
void protocore_mnt_reset(uint8_t *work)
The mount point a call names, and what registering one takes.
const protocore_mnt_backend * backend
the filesystem behind the point
uint8_t id
the point a lookup names
const char * root
the path prefix it answers for
void(*const point_add)(uint8_t *work)
const protocore_mnt_backend * backend
A storage backend. Each open call returns a small handle (>= 0) or -1.
proto_bool(* rmdir)(const char *path)
remove an empty directory; true on success.
proto_bool(* readdir)(int handle, protocore_mnt_stat *out, char *name, size_t name_cap)
Next entry: facts into out, name into name (NUL-terminated). False at end.
long(* size)(const char *path)
file size, or -1 if absent.
proto_bool(* exists)(const char *path)
true if the path exists.
int(* open)(const char *path, int mode)
-> handle (>=0) or -1.
proto_bool(* remove)(const char *path)
delete a file; true on success.
proto_bool(* mkdir)(const char *path)
create a directory; true on success.
proto_bool(* rename)(const char *from, const char *to)
rename; true on success.
int(* write)(int handle, const void *buf, size_t n)
bytes written, or -1.
void(* close)(int handle)
release a file OR directory handle.
proto_bool(* sync)(int handle)
Push everything written to handle past the backend's own buffering, and report whether it got there....
proto_bool(* stat)(const char *path, protocore_mnt_stat *out)
fill out for path; false if absent.
int(* opendir)(const char *path)
-> directory handle (>=0) or -1.
proto_bool(* seek)(int handle, uint64_t off)
absolute seek; false if unsupported.
int(* read)(int handle, void *buf, size_t n)
bytes read, or -1.
What a stat and a directory entry both answer: the facts about one file, and no name.
uint64_t size
0 for a directory
uint32_t mtime
unix epoch seconds, 0 if the backend keeps no timestamp
#define PROTOCORE_BEGIN_DECLS
Give a header's declarations C linkage, so their symbol names carry no parameter types.
_Bool proto_bool
The truth value.
#define PROTOCORE_END_DECLS