Chapter 2. API Reference
Parameters
• partition_label: Same label as passed to esp_vfs_spiffs_register.
esp_err_t esp_spiffs_info(const char *partition_label, size_t *total_bytes, size_t *used_bytes)
Get information for SPIFFS
Return
• ESP_OK if success
• ESP_ERR_INVALID_STATE if not mounted
Parameters
• partition_label: Same label as passed to esp_vfs_spiffs_register
• [out] total_bytes: Size of the file system
• [out] used_bytes: Current used bytes in the file system
Structures
struct esp_vfs_spiffs_conf_t
Configuration structure for esp_vfs_spiffs_register.
Public Members
const char *base_path
File path prefix associated with the filesystem.
const char *partition_label
Optional, label of SPIFFS partition to use. If set to NULL, first partition with subtype=spiffs will be
used.
size_t max_files
Maximum files that could be open at the same time.
bool format_if_mount_failed
If true, it will format the file system if it fails to mount.
2.5.8 Virtual filesystem component
Overview
Virtual filesystem (VFS) component provides a unified interface for drivers which can perform operations on file-like
objects. These can be real filesystems (FAT, SPIFFS, etc.) or device drivers which provide a file-like interface.
This component allows C library functions, such as fopen and fprintf, to work with FS drivers. At a high level, each FS
driver is associated with some path prefix. When one of C library functions needs to open a file, the VFS component
searches for the FS driver associated with the file path and forwards the call to that driver. VFS also forwards read,
write, and other calls for the given file to the same FS driver.
For example, one can register a FAT filesystem driver with the /fat prefix and call fopen("/fat/file.txt",
"w"). The VFS component will then call the function open of the FAT driver and pass the argument /file.txt
to it together with appropriate mode flags. All subsequent calls to C library functions for the returned FILE* stream
will also be forwarded to the FAT driver.
FS registration
To register an FS driver, an application needs to define an instance of the esp_vfs_t structure and populate it with
function pointers to FS APIs:
Espressif Systems 768
Submit Document Feedback
Release v4.4