Chapter 2. API Reference
int esp_vfs_link(struct _reent *r, const char *n1, const char *n2)
int esp_vfs_unlink(struct _reent *r, const char *path)
int esp_vfs_rename(struct _reent *r, const char *src, const char *dst)
int esp_vfs_utime(const char *path, const struct utimbuf *times)
esp_err_t
esp_vfs_register(const char *base_path, const
Register a virtual filesystem for given path prefix.
Return ESP_OK if successful, ESP_ERR_NO_MEM if too many VFSes are registered.
Parameters
• base_path: file path prefix associated with the filesystem. Must be a zero-terminated C string,
may be empty. If not empty, must be up to ESP_VFS_PATH_MAX characters long, and at least 2
characters long. Name must start with a"/"and must not end with"/". For example,"/data"or
"/dev/spi" are valid. These VFSes would then be called to handle file paths such as"/data/myfile.txt"
or "/dev/spi/0". In the special case of an empty base_path, a "fallback"VFS is registered. Such
VFS will handle paths which are not matched by any other registered VFS.
• vfs: Pointer to esp_vfs_t, a structure which maps syscalls to the filesystem driver functions. VFS
component doesn't assume ownership of this pointer.
• ctx: If vfs->flags has ESP_VFS_FLAG_CONTEXT_PTR set, a pointer which should be passed
to VFS functions. Otherwise, NULL.
esp_err_t
esp_vfs_register_fd_range(const
Special case function for registering a VFS that uses a method other than open() to open new file descriptors
from the interval <min_fd; max_fd).
This is a special-purpose function intended for registering LWIP sockets to VFS.
Return ESP_OK
ESP_ERR_INVALID_ARG if the file descriptor boundaries are incorrect.
Parameters
• vfs: Pointer to esp_vfs_t. Meaning is the same as for esp_vfs_register().
• ctx: Pointer to context structure. Meaning is the same as for esp_vfs_register().
• min_fd: The smallest file descriptor this VFS will use.
• max_fd: Upper boundary for file descriptors this VFS will use (the biggest file descriptor plus one).
esp_err_t
esp_vfs_register_with_id(const
Special case function for registering a VFS that uses a method other than open() to open new file descriptors. In
comparison with esp_vfs_register_fd_range, this function doesn't pre-registers an interval of file descriptors.
File descriptors can be registered later, by using esp_vfs_register_fd.
Return ESP_OK
ESP_ERR_INVALID_ARG if the file descriptor boundaries are incorrect.
Parameters
• vfs: Pointer to esp_vfs_t. Meaning is the same as for esp_vfs_register().
• ctx: Pointer to context structure. Meaning is the same as for esp_vfs_register().
• vfs_id: Here will be written the VFS ID which can be passed to esp_vfs_register_fd for registering
file descriptors.
esp_err_t
esp_vfs_unregister(const char *base_path)
Unregister a virtual filesystem for given path prefix
Return ESP_OK if successful, ESP_ERR_INVALID_STATE if VFS for given prefix hasn' t been registered
Parameters
• base_path: file prefix previously used in esp_vfs_register call
esp_err_t esp_vfs_unregister_with_id(esp_vfs_id_t
Unregister a virtual filesystem with the given index
Return ESP_OK if successful, ESP_ERR_INVALID_STATE if VFS for the given index hasn't been reg-
istered
Parameters
• vfs_id: The VFS ID returned by esp_vfs_register_with_id
Espressif Systems
if
successful,
ESP_ERR_NO_MEM
if
successful,
ESP_ERR_NO_MEM
Submit Document Feedback
esp_vfs_t
*vfs, void *ctx)
esp_vfs_t
*vfs, void *ctx, int min_fd, int max_fd)
if
too
many
esp_vfs_t
*vfs, void *ctx,
esp_vfs_id_t
if
too
many
vfs_id)
773
VFSes
are
registered,
*vfs_id)
VFSes
are
registered,
Release v4.4
Need help?
Do you have a question about the ESP32-S2 and is the answer not in the manual?