ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
protocore_mnt_backend Struct Reference

A storage backend. Each open call returns a small handle (>= 0) or -1. More...

#include <mnt.h>

Public Attributes

int(* open )(const char *path, int mode)
 -> handle (>=0) or -1.
 
int(* read )(int handle, void *buf, size_t n)
 bytes read, or -1.
 
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(* seek )(int handle, uint64_t off)
 absolute seek; false if unsupported.
 
long(* size )(const char *path)
 file size, or -1 if absent.
 
proto_bool(* exists )(const char *path)
 true if the path exists.
 
proto_bool(* remove )(const char *path)
 delete a file; true on success.
 
proto_bool(* rename )(const char *from, const char *to)
 rename; true on success.
 
proto_bool(* mkdir )(const char *path)
 create a directory; true on success.
 
proto_bool(* rmdir )(const char *path)
 remove an empty directory; true on success.
 
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(* 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.
 
proto_bool(* sync )(int handle)
 Push everything written to handle past the backend's own buffering, and report whether it got there. May be NULL when the backend cannot promise it.
 

Detailed Description

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.

Definition at line 87 of file mnt.h.

Member Data Documentation

◆ open

int(* protocore_mnt_backend::open) (const char *path, int mode)

-> handle (>=0) or -1.

Definition at line 89 of file mnt.h.

◆ read

int(* protocore_mnt_backend::read) (int handle, void *buf, size_t n)

bytes read, or -1.

Definition at line 90 of file mnt.h.

◆ write

int(* protocore_mnt_backend::write) (int handle, const void *buf, size_t n)

bytes written, or -1.

Definition at line 91 of file mnt.h.

◆ close

void(* protocore_mnt_backend::close) (int handle)

release a file OR directory handle.

Definition at line 92 of file mnt.h.

◆ seek

proto_bool(* protocore_mnt_backend::seek) (int handle, uint64_t off)

absolute seek; false if unsupported.

Definition at line 93 of file mnt.h.

◆ size

long(* protocore_mnt_backend::size) (const char *path)

file size, or -1 if absent.

Definition at line 94 of file mnt.h.

◆ exists

proto_bool(* protocore_mnt_backend::exists) (const char *path)

true if the path exists.

Definition at line 95 of file mnt.h.

◆ remove

proto_bool(* protocore_mnt_backend::remove) (const char *path)

delete a file; true on success.

Definition at line 96 of file mnt.h.

◆ rename

proto_bool(* protocore_mnt_backend::rename) (const char *from, const char *to)

rename; true on success.

Definition at line 97 of file mnt.h.

◆ mkdir

proto_bool(* protocore_mnt_backend::mkdir) (const char *path)

create a directory; true on success.

Definition at line 98 of file mnt.h.

◆ rmdir

proto_bool(* protocore_mnt_backend::rmdir) (const char *path)

remove an empty directory; true on success.

Definition at line 99 of file mnt.h.

◆ stat

proto_bool(* protocore_mnt_backend::stat) (const char *path, protocore_mnt_stat *out)

fill out for path; false if absent.

Definition at line 100 of file mnt.h.

◆ opendir

int(* protocore_mnt_backend::opendir) (const char *path)

-> directory handle (>=0) or -1.

Definition at line 101 of file mnt.h.

◆ readdir

proto_bool(* protocore_mnt_backend::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.

Definition at line 103 of file mnt.h.

◆ sync

proto_bool(* protocore_mnt_backend::sync) (int handle)

Push everything written to handle past the backend's own buffering, and report whether it got there. May be NULL when the backend cannot promise it.

This is the durability barrier, and it is the one call here whose absence is not the same as failure: a log that orders its writes around a barrier is only power-loss-safe if the barrier is real, so a backend that cannot make the promise says so with NULL and the caller refuses to mount rather than running as though it had one. Returning true without doing anything would make an unsafe store indistinguishable from a safe one.

Definition at line 114 of file mnt.h.


The documentation for this struct was generated from the following file: