Skip to content
/ ramfs Public

A memory based file system for embedded use.

License

Notifications You must be signed in to change notification settings

jkent/ramfs

Repository files navigation

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:

  • base_path - path to mount the ramfs
  • fs - a ramfs_fs_t instance
  • max_files - max number of files that can be open at a time
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: