jkent / ramfs

A memory based file system for embedded use.
https://ramfs.readthedocs.io
Mozilla Public License 2.0
4 stars 2 forks source link
esp-idf esp-idf-component esp32 filesystem ram

About RamFS

RamFS is a memory based filesystem designed for embedded use. It can be easily used with a CMake project — including ESP-IDF.

Getting started with ESP-IDF

To use this component with ESP-IDF, within your projects directory run

idf.py add-dependency jkent/ramfs

Usage

Two interfaces are available: the bare API or when using IDF there is the VFS interface which builds on top of the bare API. You should use the VFS interface in IDF projects, as it uses the portable and familiar posix and stdio C functions with it. There is nothing preventing you from mix and matching both at the same time, however.

Shared initialization

Initialization is as simple as calling ramfs_init function and checking its return variable:

ramfs_fs_t *fs = ramfs_init();
assert(fs != NULL);

When done, and all file handles are closed, you can call ramfs_deinit:

ramfs_deinit(fs);

VFS interface

The VFS interface adds another step to the initialization: you define a ramfs_vfs_conf_t structure:

ramfs_vfs_conf_t ramfs_vfs_conf = {
    .base_path = "/ramfs",
    .fs = fs,
    .max_files = 5,
};
ramfs_vfs_register(&ramfs_vfs_conf);

Bare API

Filesystem functions:

Object functions:

Directory Functions: