CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
host_api_fs.cpp File Reference

Sandboxed file storage for plugins on the plugins FAT partition. More...

#include "plugin_manager/host_api.h"
#include "plugin_manager/Plugin.h"
#include "plugin_manager/PluginStorage.h"
#include "cdc_core/Raii.h"
#include <cstdio>
#include <cstring>
#include <string>
#include <sys/stat.h>
#include <dirent.h>

Go to the source code of this file.

Functions

void * plg_get_active_plugin (void)
int host_fs_write (const char *name, const uint8_t *data, size_t len)
 Create or overwrite name with len bytes.
int host_fs_read (const char *name, uint8_t *buf, size_t *len)
 Read name into buf.
int host_fs_remove (const char *name)
 Delete name.
int host_fs_size (const char *name, size_t *out)
 Write the byte size of name to *out.
int host_fs_list (char *out, size_t *out_len)
 Enumerate the plugin's own files.
int host_fs_view (const char *name)
 Open one of the plugin's own files in a scrollable on-screen text viewer (same as opening the file in the vFAT explorer). Useful for a bundled readme / help page.

Detailed Description

Sandboxed file storage for plugins on the plugins FAT partition.

Each plugin gets a private directory <plugins>/data/<id>/ derived from the active plugin's id. The plugin only ever passes a bare filename; the host builds the full path and rejects anything that could escape the folder, so cross-plugin and out-of-sandbox access is physically impossible. Gated on the vFAT file storage (plugin-sandboxed) capability.

Definition in file host_api_fs.cpp.

Function Documentation

◆ plg_get_active_plugin()

void * plg_get_active_plugin ( void )

Definition at line 24 of file plugin_log_bridge.cpp.