CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
vFAT file storage (plugin-sandboxed)

Sandboxed file access on the plugins FAT partition. More...

Functions

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 access on the plugins FAT partition.

Each plugin can only touch files in its own private folder; the host builds and confines every path. Requires the vFAT file storage (plugin-sandboxed) capability. name is a bare filename: characters [A-Za-z0-9._-], no path separators, no leading dot, at most 64 bytes.

Function Documentation

◆ host_fs_list()

int host_fs_list ( char * out,
size_t * out_len )

Enumerate the plugin's own files.

Parameters
out_lenIn: capacity of out; out: bytes written ('
'-separated list).

Definition at line 121 of file host_api_fs.cpp.

References HOST_ERR_INVALID_ARG, HOST_ERR_NOT_FOUND, and HOST_OK.

Referenced by cdc::plugin_manager::w_host_fs_list().

◆ host_fs_read()

int host_fs_read ( const char * name,
uint8_t * buf,
size_t * len )

Read name into buf.

Parameters
lenIn: capacity of buf; out: bytes actually read.
Returns
HOST_OK, HOST_ERR_NOT_FOUND, or another HOST_ERR_*.

Definition at line 87 of file host_api_fs.cpp.

References HOST_ERR_INVALID_ARG, HOST_ERR_NOT_FOUND, HOST_OK, name, and cdc::core::openFile().

Referenced by cdc::plugin_manager::w_host_fs_read().

◆ host_fs_remove()

int host_fs_remove ( const char * name)

Delete name.

Returns
HOST_OK or HOST_ERR_NOT_FOUND.

Definition at line 100 of file host_api_fs.cpp.

References HOST_ERR_NOT_FOUND, HOST_OK, and name.

Referenced by cdc::plugin_manager::w_host_fs_remove().

◆ host_fs_size()

int host_fs_size ( const char * name,
size_t * out )

Write the byte size of name to *out.

Returns
HOST_OK or HOST_ERR_NOT_FOUND.

Definition at line 108 of file host_api_fs.cpp.

References HOST_ERR_INVALID_ARG, HOST_ERR_NOT_FOUND, HOST_OK, and name.

Referenced by cdc::plugin_manager::w_host_fs_size().

◆ host_fs_view()

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.

Returns
HOST_OK or a HOST_ERR_* code.

Definition at line 147 of file host_api_fs.cpp.

References HOST_ERR_NOT_FOUND, HOST_OK, host_ui_push_info(), name, and cdc::core::openFile().

Referenced by cdc::plugin_manager::w_host_fs_view().

◆ host_fs_write()

int host_fs_write ( const char * name,
const uint8_t * data,
size_t len )

Create or overwrite name with len bytes.

Returns
HOST_OK or HOST_ERR_*.

Definition at line 74 of file host_api_fs.cpp.

References HOST_ERR_GENERIC, HOST_ERR_INVALID_ARG, HOST_OK, name, and cdc::core::openFile().

Referenced by cdc::plugin_manager::w_host_fs_write().