VSF Documented
esp_vfs_ops.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2026 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18/*
19 * esp_vfs_ops.h -- ESP-IDF VFS operations types (clean-room).
20 *
21 * This header defines the modular esp_vfs_fs_ops_t type introduced in
22 * ESP-IDF v5.2+. The older monolithic esp_vfs_t (in esp_vfs.h) is
23 * deprecated in favour of this struct. All production drivers (FATFS,
24 * SPIFFS, UART, nullfs, semihost, etc.) use esp_vfs_fs_ops_t with
25 * per-category sub-structs (dir, termios, select).
26 */
27
28#ifndef __VSF_ESPIDF_ESP_VFS_OPS_H__
29#define __VSF_ESPIDF_ESP_VFS_OPS_H__
30
31/*============================ INCLUDES ======================================*/
32
33#include <stdint.h>
34#include <stddef.h>
35#include <stdarg.h>
36#include <stdbool.h>
37#include <unistd.h>
38#include <sys/types.h>
39#include <sys/stat.h>
40#include <sys/time.h>
41#include <dirent.h>
42#include "esp_err.h"
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
48/*============================ TYPES =========================================*/
49
50/*
51 * VFS identification number returned by esp_vfs_register_with_id() /
52 * esp_vfs_register_fs_with_id().
53 */
54typedef int esp_vfs_id_t;
55
56/*
57 * Select notification semaphore, used by drivers to signal I/O readiness
58 * back to the VFS select/poll dispatcher.
59 */
60typedef struct {
62 void *sem;
64
65/*============================ BASIC FILE OPERATION TYPES ====================*/
66
67typedef ssize_t (*esp_vfs_write_ctx_op_t) (void *ctx, int fd,
68 const void *data, size_t size);
69typedef ssize_t (*esp_vfs_write_op_t) ( int fd,
70 const void *data, size_t size);
71typedef off_t (*esp_vfs_lseek_ctx_op_t) (void *ctx, int fd,
72 off_t size, int mode);
73typedef off_t (*esp_vfs_lseek_op_t) ( int fd,
74 off_t size, int mode);
75typedef ssize_t (*esp_vfs_read_ctx_op_t) (void *ctx, int fd,
76 void *dst, size_t size);
77typedef ssize_t (*esp_vfs_read_op_t) ( int fd,
78 void *dst, size_t size);
79typedef ssize_t (*esp_vfs_pread_ctx_op_t) (void *ctx, int fd,
80 void *dst, size_t size, off_t offset);
81typedef ssize_t (*esp_vfs_pread_op_t) ( int fd,
82 void *dst, size_t size, off_t offset);
83typedef ssize_t (*esp_vfs_pwrite_ctx_op_t)(void *ctx, int fd,
84 const void *src, size_t size,
86typedef ssize_t (*esp_vfs_pwrite_op_t) ( int fd,
87 const void *src, size_t size,
89typedef int (*esp_vfs_open_ctx_op_t) (void *ctx, const char *path,
90 int flags, int mode);
91typedef int (*esp_vfs_open_op_t) ( const char *path,
92 int flags, int mode);
93typedef int (*esp_vfs_close_ctx_op_t) (void *ctx, int fd);
94typedef int (*esp_vfs_close_op_t) ( int fd);
95typedef int (*esp_vfs_fstat_ctx_op_t) (void *ctx, int fd, struct stat *st);
96typedef int (*esp_vfs_fstat_op_t) ( int fd, struct stat *st);
97typedef int (*esp_vfs_fcntl_ctx_op_t) (void *ctx, int fd,
98 int cmd, int arg);
99typedef int (*esp_vfs_fcntl_op_t) ( int fd,
100 int cmd, int arg);
101typedef int (*esp_vfs_ioctl_ctx_op_t) (void *ctx, int fd,
102 int cmd, va_list args);
103typedef int (*esp_vfs_ioctl_op_t) ( int fd,
104 int cmd, va_list args);
105typedef int (*esp_vfs_fsync_ctx_op_t) (void *ctx, int fd);
106typedef int (*esp_vfs_fsync_op_t) ( int fd);
107
108/*============================ DIRECTORY OPERATION TYPES =====================*/
109
110typedef int (*esp_vfs_stat_ctx_op_t) (void *ctx,
111 const char *path, struct stat *st);
112typedef int (*esp_vfs_stat_op_t) (
113 const char *path, struct stat *st);
114typedef int (*esp_vfs_link_ctx_op_t) (void *ctx,
115 const char *n1, const char *n2);
116typedef int (*esp_vfs_link_op_t) (
117 const char *n1, const char *n2);
118typedef int (*esp_vfs_unlink_ctx_op_t) (void *ctx,
119 const char *path);
120typedef int (*esp_vfs_unlink_op_t) (
121 const char *path);
122typedef int (*esp_vfs_rename_ctx_op_t) (void *ctx,
123 const char *src, const char *dst);
124typedef int (*esp_vfs_rename_op_t) (
125 const char *src, const char *dst);
126typedef DIR* (*esp_vfs_opendir_ctx_op_t) (void *ctx,
127 const char *name);
128typedef DIR* (*esp_vfs_opendir_op_t) (
129 const char *name);
130typedef struct dirent* (*esp_vfs_readdir_ctx_op_t) (void *ctx, DIR *pdir);
131typedef struct dirent* (*esp_vfs_readdir_op_t) ( DIR *pdir);
132typedef int (*esp_vfs_readdir_r_ctx_op_t)(void *ctx, DIR *pdir,
133 struct dirent *entry,
134 struct dirent **out);
135typedef int (*esp_vfs_readdir_r_op_t) ( DIR *pdir,
136 struct dirent *entry,
137 struct dirent **out);
138typedef long (*esp_vfs_telldir_ctx_op_t) (void *ctx, DIR *pdir);
139typedef long (*esp_vfs_telldir_op_t) ( DIR *pdir);
140typedef void (*esp_vfs_seekdir_ctx_op_t) (void *ctx, DIR *pdir,
141 long offset);
142typedef void (*esp_vfs_seekdir_op_t) ( DIR *pdir,
143 long offset);
144typedef int (*esp_vfs_closedir_ctx_op_t) (void *ctx, DIR *pdir);
145typedef int (*esp_vfs_closedir_op_t) ( DIR *pdir);
146typedef int (*esp_vfs_mkdir_ctx_op_t) (void *ctx,
147 const char *name, mode_t mode);
148typedef int (*esp_vfs_mkdir_op_t) (
149 const char *name, mode_t mode);
150typedef int (*esp_vfs_rmdir_ctx_op_t) (void *ctx,
151 const char *name);
152typedef int (*esp_vfs_rmdir_op_t) (
153 const char *name);
154typedef int (*esp_vfs_access_ctx_op_t) (void *ctx,
155 const char *path, int amode);
156typedef int (*esp_vfs_access_op_t) (
157 const char *path, int amode);
158typedef int (*esp_vfs_truncate_ctx_op_t) (void *ctx,
159 const char *path, off_t length);
160typedef int (*esp_vfs_truncate_op_t) (
161 const char *path, off_t length);
162typedef int (*esp_vfs_ftruncate_ctx_op_t)(void *ctx, int fd,
163 off_t length);
164typedef int (*esp_vfs_ftruncate_op_t) ( int fd,
165 off_t length);
166
167typedef struct {
168 union {
171 };
172 union {
175 };
176 union {
179 };
180 union {
183 };
184 union {
187 };
188 union {
191 };
192 union {
195 };
196 union {
199 };
200 union {
203 };
204 union {
207 };
208 union {
211 };
212 union {
215 };
216 union {
219 };
220 union {
223 };
224 union {
227 };
229
230/*============================ MAIN VFS OPERATIONS STRUCT ====================*/
231
232typedef struct {
233 union {
236 };
237 union {
240 };
241 union {
244 };
245 union {
248 };
249 union {
252 };
253 union {
256 };
257 union {
260 };
261 union {
264 };
265 union {
268 };
269 union {
272 };
273 union {
276 };
277
280
281/*============================ REGISTRATION PROTOTYPES =======================*/
282
283extern esp_err_t esp_vfs_register_fs(const char *base_path,
284 const esp_vfs_fs_ops_t *vfs,
285 int flags, void *ctx);
287 int flags, void *ctx,
288 esp_vfs_id_t *id);
289extern esp_err_t esp_vfs_unregister_fs(const char *base_path);
291
292#ifdef __cplusplus
293}
294#endif
295
296#endif // __VSF_ESPIDF_ESP_VFS_OPS_H__
Definition vsf_linux_fs.h:115
int esp_err_t
Definition esp_err.h:41
int(* esp_vfs_mkdir_op_t)(const char *name, mode_t mode)
Definition esp_vfs_ops.h:148
DIR *(* esp_vfs_opendir_op_t)(const char *name)
Definition esp_vfs_ops.h:128
int(* esp_vfs_ioctl_ctx_op_t)(void *ctx, int fd, int cmd, va_list args)
Definition esp_vfs_ops.h:101
int(* esp_vfs_close_ctx_op_t)(void *ctx, int fd)
Definition esp_vfs_ops.h:93
void(* esp_vfs_seekdir_op_t)(DIR *pdir, long offset)
Definition esp_vfs_ops.h:142
ssize_t(* esp_vfs_pwrite_ctx_op_t)(void *ctx, int fd, const void *src, size_t size, off_t offset)
Definition esp_vfs_ops.h:83
int(* esp_vfs_stat_op_t)(const char *path, struct stat *st)
Definition esp_vfs_ops.h:112
int(* esp_vfs_fcntl_op_t)(int fd, int cmd, int arg)
Definition esp_vfs_ops.h:99
long(* esp_vfs_telldir_op_t)(DIR *pdir)
Definition esp_vfs_ops.h:139
DIR *(* esp_vfs_opendir_ctx_op_t)(void *ctx, const char *name)
Definition esp_vfs_ops.h:126
ssize_t(* esp_vfs_pwrite_op_t)(int fd, const void *src, size_t size, off_t offset)
Definition esp_vfs_ops.h:86
int(* esp_vfs_ftruncate_op_t)(int fd, off_t length)
Definition esp_vfs_ops.h:164
int(* esp_vfs_fstat_op_t)(int fd, struct stat *st)
Definition esp_vfs_ops.h:96
off_t(* esp_vfs_lseek_ctx_op_t)(void *ctx, int fd, off_t size, int mode)
Definition esp_vfs_ops.h:71
struct dirent *(* esp_vfs_readdir_ctx_op_t)(void *ctx, DIR *pdir)
Definition esp_vfs_ops.h:130
esp_err_t esp_vfs_register_fs_with_id(const esp_vfs_fs_ops_t *vfs, int flags, void *ctx, esp_vfs_id_t *id)
Definition esp_vfs_port.c:515
int(* esp_vfs_rmdir_ctx_op_t)(void *ctx, const char *name)
Definition esp_vfs_ops.h:150
ssize_t(* esp_vfs_read_op_t)(int fd, void *dst, size_t size)
Definition esp_vfs_ops.h:77
int(* esp_vfs_access_op_t)(const char *path, int amode)
Definition esp_vfs_ops.h:156
int(* esp_vfs_fsync_op_t)(int fd)
Definition esp_vfs_ops.h:106
int(* esp_vfs_link_op_t)(const char *n1, const char *n2)
Definition esp_vfs_ops.h:116
ssize_t(* esp_vfs_pread_op_t)(int fd, void *dst, size_t size, off_t offset)
Definition esp_vfs_ops.h:81
int(* esp_vfs_truncate_ctx_op_t)(void *ctx, const char *path, off_t length)
Definition esp_vfs_ops.h:158
off_t(* esp_vfs_lseek_op_t)(int fd, off_t size, int mode)
Definition esp_vfs_ops.h:73
int(* esp_vfs_readdir_r_ctx_op_t)(void *ctx, DIR *pdir, struct dirent *entry, struct dirent **out)
Definition esp_vfs_ops.h:132
esp_err_t esp_vfs_register_fs(const char *base_path, const esp_vfs_fs_ops_t *vfs, int flags, void *ctx)
Definition esp_vfs_port.c:430
int(* esp_vfs_closedir_op_t)(DIR *pdir)
Definition esp_vfs_ops.h:145
int(* esp_vfs_fcntl_ctx_op_t)(void *ctx, int fd, int cmd, int arg)
Definition esp_vfs_ops.h:97
int(* esp_vfs_rename_ctx_op_t)(void *ctx, const char *src, const char *dst)
Definition esp_vfs_ops.h:122
esp_err_t esp_vfs_unregister_fs(const char *base_path)
Definition esp_vfs_port.c:482
int esp_vfs_id_t
Definition esp_vfs_ops.h:54
int(* esp_vfs_fsync_ctx_op_t)(void *ctx, int fd)
Definition esp_vfs_ops.h:105
int(* esp_vfs_rename_op_t)(const char *src, const char *dst)
Definition esp_vfs_ops.h:124
ssize_t(* esp_vfs_read_ctx_op_t)(void *ctx, int fd, void *dst, size_t size)
Definition esp_vfs_ops.h:75
int(* esp_vfs_rmdir_op_t)(const char *name)
Definition esp_vfs_ops.h:152
struct dirent *(* esp_vfs_readdir_op_t)(DIR *pdir)
Definition esp_vfs_ops.h:131
int(* esp_vfs_close_op_t)(int fd)
Definition esp_vfs_ops.h:94
esp_err_t esp_vfs_unregister_fs_with_id(esp_vfs_id_t id)
Definition esp_vfs_port.c:516
ssize_t(* esp_vfs_write_ctx_op_t)(void *ctx, int fd, const void *data, size_t size)
Definition esp_vfs_ops.h:67
int(* esp_vfs_closedir_ctx_op_t)(void *ctx, DIR *pdir)
Definition esp_vfs_ops.h:144
int(* esp_vfs_unlink_op_t)(const char *path)
Definition esp_vfs_ops.h:120
int(* esp_vfs_mkdir_ctx_op_t)(void *ctx, const char *name, mode_t mode)
Definition esp_vfs_ops.h:146
ssize_t(* esp_vfs_pread_ctx_op_t)(void *ctx, int fd, void *dst, size_t size, off_t offset)
Definition esp_vfs_ops.h:79
int(* esp_vfs_access_ctx_op_t)(void *ctx, const char *path, int amode)
Definition esp_vfs_ops.h:154
int(* esp_vfs_ftruncate_ctx_op_t)(void *ctx, int fd, off_t length)
Definition esp_vfs_ops.h:162
int(* esp_vfs_readdir_r_op_t)(DIR *pdir, struct dirent *entry, struct dirent **out)
Definition esp_vfs_ops.h:135
int(* esp_vfs_link_ctx_op_t)(void *ctx, const char *n1, const char *n2)
Definition esp_vfs_ops.h:114
int(* esp_vfs_ioctl_op_t)(int fd, int cmd, va_list args)
Definition esp_vfs_ops.h:103
long(* esp_vfs_telldir_ctx_op_t)(void *ctx, DIR *pdir)
Definition esp_vfs_ops.h:138
int(* esp_vfs_open_ctx_op_t)(void *ctx, const char *path, int flags, int mode)
Definition esp_vfs_ops.h:89
int(* esp_vfs_open_op_t)(const char *path, int flags, int mode)
Definition esp_vfs_ops.h:91
void(* esp_vfs_seekdir_ctx_op_t)(void *ctx, DIR *pdir, long offset)
Definition esp_vfs_ops.h:140
ssize_t(* esp_vfs_write_op_t)(int fd, const void *data, size_t size)
Definition esp_vfs_ops.h:69
int(* esp_vfs_truncate_op_t)(const char *path, off_t length)
Definition esp_vfs_ops.h:160
int(* esp_vfs_fstat_ctx_op_t)(void *ctx, int fd, struct stat *st)
Definition esp_vfs_ops.h:95
int(* esp_vfs_stat_ctx_op_t)(void *ctx, const char *path, struct stat *st)
Definition esp_vfs_ops.h:110
int(* esp_vfs_unlink_ctx_op_t)(void *ctx, const char *path)
Definition esp_vfs_ops.h:118
struct ieee80211_ext_chansw_ie data
Definition ieee80211.h:80
unsigned int mode_t
Definition types.h:115
int ssize_t
Definition types.h:91
long off_t
Definition types.h:123
Definition dirent.h:35
Definition esp_vfs_ops.h:167
esp_vfs_truncate_ctx_op_t truncate_p
Definition esp_vfs_ops.h:221
esp_vfs_telldir_op_t telldir
Definition esp_vfs_ops.h:198
esp_vfs_rename_op_t rename
Definition esp_vfs_ops.h:182
esp_vfs_rmdir_ctx_op_t rmdir_p
Definition esp_vfs_ops.h:213
esp_vfs_truncate_op_t truncate
Definition esp_vfs_ops.h:222
esp_vfs_readdir_op_t readdir
Definition esp_vfs_ops.h:190
esp_vfs_ftruncate_ctx_op_t ftruncate_p
Definition esp_vfs_ops.h:225
esp_vfs_readdir_r_op_t readdir_r
Definition esp_vfs_ops.h:194
esp_vfs_mkdir_op_t mkdir
Definition esp_vfs_ops.h:210
esp_vfs_mkdir_ctx_op_t mkdir_p
Definition esp_vfs_ops.h:209
esp_vfs_access_op_t access
Definition esp_vfs_ops.h:218
esp_vfs_opendir_op_t opendir
Definition esp_vfs_ops.h:186
esp_vfs_opendir_ctx_op_t opendir_p
Definition esp_vfs_ops.h:185
esp_vfs_unlink_op_t unlink
Definition esp_vfs_ops.h:178
esp_vfs_seekdir_ctx_op_t seekdir_p
Definition esp_vfs_ops.h:201
esp_vfs_ftruncate_op_t ftruncate
Definition esp_vfs_ops.h:226
esp_vfs_stat_ctx_op_t stat_p
Definition esp_vfs_ops.h:169
esp_vfs_rename_ctx_op_t rename_p
Definition esp_vfs_ops.h:181
esp_vfs_closedir_ctx_op_t closedir_p
Definition esp_vfs_ops.h:205
esp_vfs_link_ctx_op_t link_p
Definition esp_vfs_ops.h:173
esp_vfs_stat_op_t stat
Definition esp_vfs_ops.h:170
esp_vfs_closedir_op_t closedir
Definition esp_vfs_ops.h:206
esp_vfs_seekdir_op_t seekdir
Definition esp_vfs_ops.h:202
esp_vfs_access_ctx_op_t access_p
Definition esp_vfs_ops.h:217
esp_vfs_link_op_t link
Definition esp_vfs_ops.h:174
esp_vfs_readdir_ctx_op_t readdir_p
Definition esp_vfs_ops.h:189
esp_vfs_telldir_ctx_op_t telldir_p
Definition esp_vfs_ops.h:197
esp_vfs_readdir_r_ctx_op_t readdir_r_p
Definition esp_vfs_ops.h:193
esp_vfs_unlink_ctx_op_t unlink_p
Definition esp_vfs_ops.h:177
esp_vfs_rmdir_op_t rmdir
Definition esp_vfs_ops.h:214
Definition esp_vfs_ops.h:232
esp_vfs_pread_op_t pread
Definition esp_vfs_ops.h:247
esp_vfs_write_op_t write
Definition esp_vfs_ops.h:235
esp_vfs_ioctl_op_t ioctl
Definition esp_vfs_ops.h:271
esp_vfs_read_op_t read
Definition esp_vfs_ops.h:243
esp_vfs_ioctl_ctx_op_t ioctl_p
Definition esp_vfs_ops.h:270
esp_vfs_pwrite_op_t pwrite
Definition esp_vfs_ops.h:251
esp_vfs_open_op_t open
Definition esp_vfs_ops.h:255
esp_vfs_fsync_ctx_op_t fsync_p
Definition esp_vfs_ops.h:274
esp_vfs_pwrite_ctx_op_t pwrite_p
Definition esp_vfs_ops.h:250
esp_vfs_lseek_ctx_op_t lseek_p
Definition esp_vfs_ops.h:238
esp_vfs_write_ctx_op_t write_p
Definition esp_vfs_ops.h:234
const esp_vfs_dir_ops_t * dir
Definition esp_vfs_ops.h:278
esp_vfs_close_ctx_op_t close_p
Definition esp_vfs_ops.h:258
esp_vfs_fstat_ctx_op_t fstat_p
Definition esp_vfs_ops.h:262
esp_vfs_fcntl_op_t fcntl
Definition esp_vfs_ops.h:267
esp_vfs_read_ctx_op_t read_p
Definition esp_vfs_ops.h:242
esp_vfs_open_ctx_op_t open_p
Definition esp_vfs_ops.h:254
esp_vfs_fcntl_ctx_op_t fcntl_p
Definition esp_vfs_ops.h:266
esp_vfs_close_op_t close
Definition esp_vfs_ops.h:259
esp_vfs_lseek_op_t lseek
Definition esp_vfs_ops.h:239
esp_vfs_pread_ctx_op_t pread_p
Definition esp_vfs_ops.h:246
esp_vfs_fstat_op_t fstat
Definition esp_vfs_ops.h:263
esp_vfs_fsync_op_t fsync
Definition esp_vfs_ops.h:275
Definition esp_vfs_ops.h:60
void * sem
Definition esp_vfs_ops.h:62
bool is_sem_local
Definition esp_vfs_ops.h:61
Definition stat.h:107
uint64_t offset
Definition vsf_memfs.h:49
uint32_t size
Definition vsf_memfs.h:50
uint_fast8_t length
Definition vsf_pbuf.c:38
Generated from commit: vsfteam/vsf@c3767bf