ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
mnt.h File Reference

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.

Detailed Description

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:

  • RAM (server/storage/mnt_ram, PROTOCORE_ENABLE_MNT): a fixed pool of PROTOCORE_MNT_RAM_FILES files of up to PROTOCORE_MNT_RAM_FILE_SIZE bytes each, all in BSS - deterministic, bounded, and identical on host and target. It is what lets the SFTP/SCP/WebDAV servers run under a native test.
  • Board filesystem (board layer): wraps the framework's own file object for persistent storage. It lives in test/core_setup/ because it speaks a vendor framework, which the core does not.

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.

Author
Douglas Quigg (dstroy0)
Date
2026

Definition in file mnt.h.

Macro Definition Documentation

◆ PROTOCORE_MNT_NONE

#define PROTOCORE_MNT_NONE   0xFFu

Mount the active backend (call once at setup; NULL unmounts).

The id a route carries when it serves no mount point.

Definition at line 122 of file mnt.h.

Typedef Documentation

◆ protocore_mnt_backend

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.

Function Documentation

◆ EMBED_ENUM_BYTE()

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.

◆ protocore_mnt_point_add()

void protocore_mnt_point_add ( const uint8_t * work)

Referenced by protocore_mnt_active().

◆ protocore_mnt_point_of()

void protocore_mnt_point_of ( const uint8_t * work)

Referenced by protocore_mnt_active().

◆ protocore_mnt_root_of()

void protocore_mnt_root_of ( const uint8_t * work)

Referenced by protocore_mnt_active().

◆ protocore_mnt_reset()

void protocore_mnt_reset ( const uint8_t * work)

Referenced by protocore_mnt_active().

◆ protocore_mnt_mount()

void protocore_mnt_mount ( const uint8_t * work)

Referenced by protocore_mnt_active().

◆ protocore_mnt_active()

Variable Documentation

◆ MntV

MntVars MntV
extern

The operands and the outcome.