The mount: which store is behind the filesystem, and the vtable it answers through. More...
#include "protocore_config.h"Go to the source code of this file.
Classes | |
| struct | protocore_mnt_stat |
| What a stat and a directory entry both answer: the facts about one file, and no name. More... | |
| struct | protocore_mnt_backend |
| A storage backend. Each open call returns a small handle (>= 0) or -1. More... | |
| struct | MntArgs |
| The mount point a call names, and what registering one takes. More... | |
| struct | MntVars |
| struct | MntNs |
| The entries. More... | |
Macros | |
| #define | PROTOCORE_MNT_NONE 0xFFu |
| Mount the active backend (call once at setup; NULL unmounts). | |
Typedefs | |
| typedef struct protocore_mnt_backend | protocore_mnt_backend |
| A storage backend. Each open call returns a small handle (>= 0) or -1. | |
Functions | |
| EMBED_BEGIN_DECLS | EMBED_ENUM_BYTE (protocore_mnt_mode, PROTOCORE_MNT_READ=0, PROTOCORE_MNT_WRITE=1, PROTOCORE_MNT_APPEND=2, PROTOCORE_MNT_RDWR=3,) |
| Open modes. | |
| void | protocore_mnt_point_add (const uint8_t *work) |
| void | protocore_mnt_point_of (const uint8_t *work) |
| void | protocore_mnt_root_of (const uint8_t *work) |
| void | protocore_mnt_reset (const uint8_t *work) |
| void | protocore_mnt_mount (const uint8_t *work) |
| void | protocore_mnt_active (const uint8_t *work) |
Variables | |
| MntVars | MntV |
| The operands and the outcome. | |
The mount: which store is behind the filesystem, and the vtable it answers through.
This file answers one question - what is mounted - and nothing else. The operations a caller performs live on the filesystem accessor (server/filesystem.h), which resolves a request path against its root and then dispatches here. Splitting it that way means a backend author implements storage and never touches path policy, and the .. guard cannot be bypassed by reaching a backend directly.
Two backends ship, each its own module, because a backend is a footprint and this is a seam:
Handles are small ints the backend assigns, and a directory cursor is one of them - so ::close releases either kind and there is no second lifetime to get wrong. Every entry point fails closed (-1 / false) when nothing is mounted.
Single-accessor like the other services: use it from one context (a worker / loop), not concurrently.
Definition in file mnt.h.
| #define PROTOCORE_MNT_NONE 0xFFu |
| typedef struct protocore_mnt_backend protocore_mnt_backend |
A storage backend. Each open call returns a small handle (>= 0) or -1.
Implement this to add a store; the built-in RAM disk publishes one through MntRamNs::backend (server/storage/mnt_ram).
Every call here is one node. mnt is blind - it does not know what a path means, so it cannot know what a subtree is, and nothing here takes one. A whole-tree operation is composed from these by the accessor (server/storage/filesystem.h), which is the seam that does know.
| EMBED_BEGIN_DECLS EMBED_ENUM_BYTE | ( | protocore_mnt_mode | , |
| PROTOCORE_MNT_READ | = 0, | ||
| PROTOCORE_MNT_WRITE | = 1, | ||
| PROTOCORE_MNT_APPEND | = 2, | ||
| PROTOCORE_MNT_RDWR | = 3 ) |
Open modes.
PROTOCORE_MNT_RDWR is the only one that admits a seek before a write. Under PROTOCORE_MNT_APPEND a write lands at end-of-file whatever the position says, which is what O_APPEND means on a real filesystem, so a caller that overwrites in place has to ask for RDWR and a backend that cannot offer it answers -1.
| void protocore_mnt_point_add | ( | const uint8_t * | work | ) |
Referenced by protocore_mnt_active().
| void protocore_mnt_point_of | ( | const uint8_t * | work | ) |
Referenced by protocore_mnt_active().
| void protocore_mnt_root_of | ( | const uint8_t * | work | ) |
Referenced by protocore_mnt_active().
| void protocore_mnt_reset | ( | const uint8_t * | work | ) |
Referenced by protocore_mnt_active().
| void protocore_mnt_mount | ( | const uint8_t * | work | ) |
Referenced by protocore_mnt_active().
| void protocore_mnt_active | ( | const uint8_t * | work | ) |
References protocore_mnt_active(), protocore_mnt_mount(), protocore_mnt_point_add(), protocore_mnt_point_of(), protocore_mnt_reset(), and protocore_mnt_root_of().
Referenced by protocore_mnt_active().
|
extern |
The operands and the outcome.