VFS abstraction for portable file and directory access.
More...
|
| int | ove_fs_open_init (ove_file_t *file, ove_file_storage_t *storage, const char *path, int flags) |
| | Open a file using caller-provided static storage.
|
| |
| int | ove_fs_close_deinit (ove_file_t file) |
| | Close a statically-allocated file handle.
|
| |
| int | ove_fs_opendir_init (ove_dir_t *dir, ove_dir_storage_t *storage, const char *path) |
| | Open a directory using caller-provided static storage.
|
| |
| int | ove_fs_closedir_deinit (ove_dir_t dir) |
| | Close a statically-allocated directory handle.
|
| |
| int | ove_fs_open (ove_file_t *file, const char *path, int flags) |
| | Open a file (heap-backed handle).
|
| |
| int | ove_fs_close (ove_file_t file) |
| | Close a file handle returned by ove_fs_open.
|
| |
| int | ove_fs_opendir (ove_dir_t *dir, const char *path) |
| | Open a directory (heap-backed handle).
|
| |
| int | ove_fs_closedir (ove_dir_t dir) |
| | Close a directory handle returned by ove_fs_opendir.
|
| |
| int | ove_fs_mount (const char *dev_path, const char *mount_point) |
| | Mount a storage device at a virtual path prefix.
|
| |
| void | ove_fs_unmount (const char *mount_point) |
| | Unmount a previously mounted storage device.
|
| |
| int | ove_fs_read (ove_file_t file, void *buf, size_t count, size_t *bytes_read) |
| | Read bytes from an open file.
|
| |
| int | ove_fs_write (ove_file_t file, const void *buf, size_t count, size_t *bytes_written) |
| | Write bytes to an open file.
|
| |
| int | ove_fs_size (ove_file_t file, size_t *out_size) |
| | Query the total size of an open file.
|
| |
| int | ove_fs_seek (ove_file_t file, long offset, int whence) |
| | Reposition the file read/write offset.
|
| |
| long | ove_fs_tell (ove_file_t file) |
| | Return the current file position.
|
| |
| int | ove_fs_readdir (ove_dir_t dir, struct ove_dirent *entry) |
| | Read the next entry from an open directory.
|
| |
| int | ove_fs_unlink (const char *path) |
| | Delete a file by path.
|
| |
| int | ove_fs_rename (const char *old_path, const char *new_path) |
| | Rename or move a file.
|
| |
|
Flags passed to ove_fs_open or ove_fs_open_init. Flags may be combined with bitwise OR.
|
|
#define | OVE_FS_O_READ 0x01 |
| | Open for reading.
|
| |
|
#define | OVE_FS_O_WRITE 0x02 |
| | Open for writing.
|
| |
|
#define | OVE_FS_O_CREATE 0x04 |
| | Create the file if it does not exist.
|
| |
|
#define | OVE_FS_O_APPEND 0x08 |
| | Seek to the end of the file before each write.
|
| |
|
Passed as the whence argument to ove_fs_seek.
|
|
#define | OVE_FS_SEEK_SET 0 |
| | Seek relative to the beginning of the file.
|
| |
|
#define | OVE_FS_SEEK_CUR 1 |
| | Seek relative to the current file position.
|
| |
|
#define | OVE_FS_SEEK_END 2 |
| | Seek relative to the end of the file.
|
| |
VFS abstraction for portable file and directory access.
Provides a thin virtual file system (VFS) layer that maps POSIX-like file and directory operations onto the underlying RTOS storage backend. Volumes are mounted by path prefix, and all subsequent operations use absolute path strings.
File and directory handles follow the same dual-allocation pattern used elsewhere in oveRTOS:
- Note
- Requires
CONFIG_OVE_FS.
◆ ove_fs_open_init()
| int ove_fs_open_init |
( |
ove_file_t * |
file, |
|
|
ove_file_storage_t * |
storage, |
|
|
const char * |
path, |
|
|
int |
flags |
|
) |
| |
Open a file using caller-provided static storage.
Opens the file at path with the given flags and stores the resulting handle in file. The caller must ensure storage remains valid for the lifetime of the open file.
- Parameters
-
| [out] | file | Receives the opened file handle. |
| [in] | storage | Pointer to statically-allocated file storage. |
| [in] | path | Absolute path of the file to open. |
| [in] | flags | Combination of OVE_FS_O_* flags. |
- Returns
- OVE_OK on success, negative error code on failure.
- Note
- Requires
CONFIG_OVE_FS.
◆ ove_fs_close_deinit()
Close a statically-allocated file handle.
Flushes any pending writes and releases the RTOS file resources. The storage memory is not freed.
- Parameters
-
- Returns
- OVE_OK on success, negative error code on failure.
- Note
- Requires
CONFIG_OVE_FS.
◆ ove_fs_opendir_init()
| int ove_fs_opendir_init |
( |
ove_dir_t * |
dir, |
|
|
ove_dir_storage_t * |
storage, |
|
|
const char * |
path |
|
) |
| |
Open a directory using caller-provided static storage.
Opens the directory at path and stores the resulting handle in dir. Use ove_fs_readdir to iterate entries and ove_fs_closedir_deinit to close.
- Parameters
-
| [out] | dir | Receives the opened directory handle. |
| [in] | storage | Pointer to statically-allocated directory storage. |
| [in] | path | Absolute path of the directory to open. |
- Returns
- OVE_OK on success, negative error code on failure.
- Note
- Requires
CONFIG_OVE_FS.
◆ ove_fs_closedir_deinit()
Close a statically-allocated directory handle.
Releases the RTOS directory resources. The storage memory is not freed.
- Parameters
-
- Returns
- OVE_OK on success, negative error code on failure.
- Note
- Requires
CONFIG_OVE_FS.
◆ ove_fs_open()
| int ove_fs_open |
( |
ove_file_t * |
file, |
|
|
const char * |
path, |
|
|
int |
flags |
|
) |
| |
Open a file (heap-backed handle).
Opens the file at path with the given flags. The returned handle must be closed with ove_fs_close when no longer needed.
- Parameters
-
| [out] | file | Receives the opened file handle. |
| [in] | path | Absolute path of the file to open. |
| [in] | flags | Combination of OVE_FS_O_* flags. |
- Returns
- OVE_OK on success, negative error code on failure.
- Note
- Requires
CONFIG_OVE_FS and (per-backend) OVE_HEAP_FS. In zero-heap mode use ove_fs_open_init with caller-supplied storage instead.
◆ ove_fs_close()
Close a file handle returned by ove_fs_open.
- Parameters
-
| [in] | file | File handle to close. |
- Returns
- OVE_OK on success, negative error code on failure.
◆ ove_fs_opendir()
| int ove_fs_opendir |
( |
ove_dir_t * |
dir, |
|
|
const char * |
path |
|
) |
| |
Open a directory (heap-backed handle).
- Parameters
-
| [out] | dir | Receives the opened directory handle. |
| [in] | path | Absolute path of the directory. |
- Returns
- OVE_OK on success, negative error code on failure.
- Note
- Requires
CONFIG_OVE_FS and (per-backend) OVE_HEAP_FS. In zero-heap mode use ove_fs_opendir_init.
◆ ove_fs_closedir()
Close a directory handle returned by ove_fs_opendir.
- Parameters
-
| [in] | dir | Directory handle to close. |
- Returns
- OVE_OK on success, negative error code on failure.
◆ ove_fs_mount()
| int ove_fs_mount |
( |
const char * |
dev_path, |
|
|
const char * |
mount_point |
|
) |
| |
Mount a storage device at a virtual path prefix.
Associates the block device at dev_path with the mount point mount_point. All file and directory paths rooted at mount_point will be dispatched to this device.
- Parameters
-
| [in] | dev_path | Path identifying the storage device. |
| [in] | mount_point | Absolute path to use as the mount prefix. |
- Returns
- OVE_OK on success, negative error code on failure.
◆ ove_fs_unmount()
| void ove_fs_unmount |
( |
const char * |
mount_point | ) |
|
Unmount a previously mounted storage device.
Flushes any pending data and detaches the device associated with mount_point. All file handles under this mount point must be closed before calling this function.
- Parameters
-
◆ ove_fs_read()
| int ove_fs_read |
( |
ove_file_t |
file, |
|
|
void * |
buf, |
|
|
size_t |
count, |
|
|
size_t * |
bytes_read |
|
) |
| |
Read bytes from an open file.
Reads up to count bytes starting at the current file position into buf. The file position advances by the number of bytes actually read.
- Parameters
-
| [in] | file | Open file handle. |
| [out] | buf | Buffer to receive the data. |
| [in] | count | Maximum number of bytes to read. |
| [out] | bytes_read | Receives the number of bytes actually read, or NULL if not needed. |
- Returns
- OVE_OK on success, negative error code on failure.
◆ ove_fs_write()
| int ove_fs_write |
( |
ove_file_t |
file, |
|
|
const void * |
buf, |
|
|
size_t |
count, |
|
|
size_t * |
bytes_written |
|
) |
| |
Write bytes to an open file.
Writes up to count bytes from buf at the current file position. The file position advances by the number of bytes actually written. If the file was opened with OVE_FS_O_APPEND the write position is set to the end of file before each write.
- Parameters
-
| [in] | file | Open file handle. |
| [in] | buf | Data to write. |
| [in] | count | Number of bytes to write. |
| [out] | bytes_written | Receives the number of bytes actually written, or NULL if not needed. |
- Returns
- OVE_OK on success, negative error code on failure.
◆ ove_fs_size()
| int ove_fs_size |
( |
ove_file_t |
file, |
|
|
size_t * |
out_size |
|
) |
| |
Query the total size of an open file.
- Parameters
-
| [in] | file | Open file handle. |
| [out] | out_size | Receives the file size in bytes. |
- Returns
- OVE_OK on success, negative error code on failure.
◆ ove_fs_seek()
| int ove_fs_seek |
( |
ove_file_t |
file, |
|
|
long |
offset, |
|
|
int |
whence |
|
) |
| |
Reposition the file read/write offset.
Moves the current position of file to offset bytes relative to the position described by whence.
- Parameters
-
| [in] | file | Open file handle. |
| [in] | offset | Byte offset relative to whence. |
| [in] | whence | One of OVE_FS_SEEK_SET, OVE_FS_SEEK_CUR, or OVE_FS_SEEK_END. |
- Returns
- OVE_OK on success, negative error code on failure.
◆ ove_fs_tell()
Return the current file position.
- Parameters
-
| [in] | file | Open file handle. |
- Returns
- Current byte offset from the start of the file, or -1 on error.
◆ ove_fs_readdir()
Read the next entry from an open directory.
Fills entry with information about the next directory entry and advances the internal iterator. Returns a specific error when no more entries are available.
- Parameters
-
| [in] | dir | Open directory handle. |
| [out] | entry | Pointer to a ove_dirent structure to fill. |
- Returns
- OVE_OK if an entry was read,
OVE_ERR_EOF when the directory is exhausted, or another negative error code on failure.
◆ ove_fs_unlink()
| int ove_fs_unlink |
( |
const char * |
path | ) |
|
Delete a file by path.
Removes the file at path from the file system. The file must not currently be open.
- Parameters
-
| [in] | path | Absolute path of the file to delete. |
- Returns
- OVE_OK on success, negative error code on failure.
◆ ove_fs_rename()
| int ove_fs_rename |
( |
const char * |
old_path, |
|
|
const char * |
new_path |
|
) |
| |
Rename or move a file.
Renames the file or directory at old_path to new_path. Both paths must reside on the same mounted volume.
- Parameters
-
| [in] | old_path | Absolute path of the existing file or directory. |
| [in] | new_path | Absolute path for the new name or location. |
- Returns
- OVE_OK on success, negative error code on failure.