File syn_vfs.h¶
FileList > src > syntropic > storage > syn_vfs.h
Go to the source code of this file
Virtual File System (VFS) abstraction layer.
#include "../common/syn_defs.h"#include <stdbool.h>#include <stddef.h>#include <stdint.h>
Classes¶
| Type | Name |
|---|---|
| struct | SYN_VfsDir Open directory descriptor. |
| struct | SYN_VfsDirEnt Directory entry returned by syn_vfs_readdir() . |
| struct | SYN_VfsFile Open file descriptor. |
| struct | SYN_VfsMount Mount point binding a path prefix to a filesystem. |
| struct | SYN_VfsOps VFS operations structure. Implement these for your filesystem (e.g. LittleFS). |
Public Functions¶
| Type | Name |
|---|---|
| int | syn_vfs_close (int fd) Close an open file descriptor. |
| int | syn_vfs_closedir (int dd) Close an open directory descriptor. |
| void | syn_vfs_init (void) Initialize the VFS registry. Clears all mounts and descriptors. |
| int | syn_vfs_mkdir (const char * path) Create a directory. |
| SYN_Status | syn_vfs_mount (const char * prefix, const SYN_VfsOps * ops, void * fs_data) Mount a filesystem at a path prefix. |
| int | syn_vfs_open (const char * path, int flags) Open a file. |
| int | syn_vfs_opendir (const char * path) Open a directory for iteration. |
| int | syn_vfs_read (int fd, void * buf, size_t len) Read from an open file. |
| int | syn_vfs_readdir (int dd, SYN_VfsDirEnt * ent) Read the next directory entry. |
| int | syn_vfs_rename (const char * old_path, const char * new_path) Rename or move a file. |
| int32_t | syn_vfs_seek (int fd, int32_t offset, int whence) Seek in an open file. |
| int | syn_vfs_stat (const char * path, SYN_VfsDirEnt * ent) Get status information for a file or directory. |
| int32_t | syn_vfs_tell (int fd) Get current position in an open file. |
| int | syn_vfs_unlink (const char * path) Delete a file. |
| SYN_Status | syn_vfs_unmount (const char * prefix) Unmount a filesystem by path prefix. |
| int | syn_vfs_write (int fd, const void * buf, size_t len) Write to an open file. |
Public Functions Documentation¶
function syn_vfs_close¶
Close an open file descriptor.
Parameters:
fdFile descriptor returned by syn_vfs_open().
Returns:
0 on success, or negative error code.
function syn_vfs_closedir¶
Close an open directory descriptor.
Parameters:
ddDirectory descriptor.
Returns:
0 on success, or negative error code.
function syn_vfs_init¶
Initialize the VFS registry. Clears all mounts and descriptors.
function syn_vfs_mkdir¶
Create a directory.
Parameters:
pathAbsolute path including mount prefix.
Returns:
0 on success, or negative error code.
function syn_vfs_mount¶
Mount a filesystem at a path prefix.
Parameters:
prefixMount path prefix (e.g. "/flash").opsFilesystem operations vtable.fs_dataOpaque filesystem context (e.g. lfs_t *).
Returns:
SYN_OK on success, SYN_ERROR if table is full or prefix exists.
function syn_vfs_open¶
Open a file.
Parameters:
pathAbsolute path including mount prefix.flagsCombination of SYN_O_* flags.
Returns:
File descriptor (>= 0) on success, or negative error code.
function syn_vfs_opendir¶
Open a directory for iteration.
Parameters:
pathAbsolute path including mount prefix.
Returns:
Directory descriptor (>= 0) on success, or negative error code.
function syn_vfs_read¶
Read from an open file.
Parameters:
fdFile descriptor.bufDestination buffer.lenMaximum bytes to read.
Returns:
Bytes read on success, or negative error code.
function syn_vfs_readdir¶
Read the next directory entry.
Parameters:
ddDirectory descriptor returned by syn_vfs_opendir().ent[out] Filled with the next entry.
Returns:
1 if an entry was read, 0 at end-of-directory, or negative error.
function syn_vfs_rename¶
Rename or move a file.
Parameters:
old_pathAbsolute source path.new_pathAbsolute destination path.
Returns:
0 on success, or negative error code.
function syn_vfs_seek¶
Seek in an open file.
Parameters:
fdFile descriptor.offsetByte offset.whenceSYN_SEEK_SET, SYN_SEEK_CUR, or SYN_SEEK_END.
Returns:
New absolute offset on success, or negative error code.
function syn_vfs_stat¶
Get status information for a file or directory.
Parameters:
pathAbsolute path including mount prefix.ent[out] Status information.
Returns:
0 on success, or negative error code.
function syn_vfs_tell¶
Get current position in an open file.
Parameters:
fdFile descriptor.
Returns:
Current offset, or negative error code.
function syn_vfs_unlink¶
Delete a file.
Parameters:
pathAbsolute path including mount prefix.
Returns:
0 on success, or negative error code.
function syn_vfs_unmount¶
Unmount a filesystem by path prefix.
Parameters:
prefixMount path prefix.
Returns:
SYN_OK on success, SYN_ERROR if not found or busy.
function syn_vfs_write¶
Write to an open file.
Parameters:
fdFile descriptor.bufSource buffer.lenBytes to write.
Returns:
Bytes written on success, or negative error code.
The documentation for this class was generated from the following file src/syntropic/storage/syn_vfs.h