XFusion API v1.3.0
载入中...
搜索中...
未找到
xf_vfs_ops.h
浏览该文件的文档.
1
9/*
10 * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
11 *
12 * SPDX-License-Identifier: Apache-2.0
13 */
14
27#ifndef __XF_VFS_OPS_H__
28#define __XF_VFS_OPS_H__
29
30/* ==================== [Includes] ========================================== */
31
33
34#include "xf_vfs_types.h"
35
36#ifdef __cplusplus
37extern "C" {
38#endif
39
47/* ==================== [Defines] =========================================== */
48
49/* ==================== [Typedefs] ========================================== */
50
51#if XF_VFS_SUPPORT_DIR_IS_ENABLE
52/* *INDENT-OFF* */
53
54typedef int (*xf_vfs_stat_ctx_op_t) (void *ctx, const char *path, xf_vfs_stat_t *st);
55typedef int (*xf_vfs_stat_op_t) ( const char *path, xf_vfs_stat_t *st);
56typedef int (*xf_vfs_link_ctx_op_t) (void *ctx, const char *n1, const char *n2);
57typedef int (*xf_vfs_link_op_t) ( const char *n1, const char *n2);
58typedef int (*xf_vfs_unlink_ctx_op_t) (void *ctx, const char *path);
59typedef int (*xf_vfs_unlink_op_t) ( const char *path);
60typedef int (*xf_vfs_rename_ctx_op_t) (void *ctx, const char *src, const char *dst);
61typedef int (*xf_vfs_rename_op_t) ( const char *src, const char *dst);
62typedef xf_vfs_dir_t* (*xf_vfs_opendir_ctx_op_t) (void *ctx, const char *name);
63typedef xf_vfs_dir_t* (*xf_vfs_opendir_op_t) ( const char *name);
64typedef xf_vfs_dirent_t* (*xf_vfs_readdir_ctx_op_t) (void *ctx, xf_vfs_dir_t *pdir);
65typedef xf_vfs_dirent_t* (*xf_vfs_readdir_op_t) ( xf_vfs_dir_t *pdir);
66typedef int (*xf_vfs_readdir_r_ctx_op_t) (void *ctx, xf_vfs_dir_t *pdir, xf_vfs_dirent_t *entry, xf_vfs_dirent_t **out);
67typedef int (*xf_vfs_readdir_r_op_t) ( xf_vfs_dir_t *pdir, xf_vfs_dirent_t *entry, xf_vfs_dirent_t **out);
68typedef long (*xf_vfs_telldir_ctx_op_t) (void *ctx, xf_vfs_dir_t *pdir);
69typedef long (*xf_vfs_telldir_op_t) ( xf_vfs_dir_t *pdir);
70typedef void (*xf_vfs_seekdir_ctx_op_t) (void *ctx, xf_vfs_dir_t *pdir, long offset);
71typedef void (*xf_vfs_seekdir_op_t) ( xf_vfs_dir_t *pdir, long offset);
72typedef int (*xf_vfs_closedir_ctx_op_t) (void *ctx, xf_vfs_dir_t *pdir);
73typedef int (*xf_vfs_closedir_op_t) ( xf_vfs_dir_t *pdir);
74typedef int (*xf_vfs_mkdir_ctx_op_t) (void *ctx, const char *name, xf_vfs_mode_t mode);
75typedef int (*xf_vfs_mkdir_op_t) ( const char *name, xf_vfs_mode_t mode);
76typedef int (*xf_vfs_rmdir_ctx_op_t) (void *ctx, const char *name);
77typedef int (*xf_vfs_rmdir_op_t) ( const char *name);
78typedef int (*xf_vfs_access_ctx_op_t) (void *ctx, const char *path, int amode);
79typedef int (*xf_vfs_access_op_t) ( const char *path, int amode);
80typedef int (*xf_vfs_truncate_ctx_op_t) (void *ctx, const char *path, xf_vfs_off_t length);
81typedef int (*xf_vfs_truncate_op_t) ( const char *path, xf_vfs_off_t length);
82typedef int (*xf_vfs_ftruncate_ctx_op_t) (void *ctx, int fd, xf_vfs_off_t length);
83typedef int (*xf_vfs_ftruncate_op_t) ( int fd, xf_vfs_off_t length);
84typedef int (*xf_vfs_utime_ctx_op_t) (void *ctx, const char *path, const xf_vfs_utimbuf_t *times);
85typedef int (*xf_vfs_utime_op_t) ( const char *path, const xf_vfs_utimbuf_t *times);
90typedef struct {
91 union {
94 };
95 union {
98 };
99 union {
102 };
103 union {
106 };
107 union {
110 };
111 union {
114 };
115 union {
118 };
119 union {
122 };
123 union {
126 };
127 union {
130 };
131 union {
134 };
135 union {
138 };
139 union {
142 };
143 union {
146 };
147 union {
150 };
151 union {
154 };
156
157/* *INDENT-ON* */
158#endif // CONFIG_XF_VFS_SUPPORT_DIR
159
160/* *INDENT-OFF* */
161
162typedef xf_vfs_ssize_t (*xf_vfs_write_ctx_op_t) (void *ctx, int fd, const void *data, size_t size);
163typedef xf_vfs_ssize_t (*xf_vfs_write_op_t) ( int fd, const void *data, size_t size);
164typedef xf_vfs_off_t (*xf_vfs_lseek_ctx_op_t) (void *ctx, int fd, xf_vfs_off_t size, int mode);
165typedef xf_vfs_off_t (*xf_vfs_lseek_op_t) ( int fd, xf_vfs_off_t size, int mode);
166typedef xf_vfs_ssize_t (*xf_vfs_read_ctx_op_t) (void *ctx, int fd, void *dst, size_t size);
167typedef xf_vfs_ssize_t (*xf_vfs_read_op_t) ( int fd, void *dst, size_t size);
168typedef xf_vfs_ssize_t (*xf_vfs_pread_ctx_op_t) (void *ctx, int fd, void *dst, size_t size, xf_vfs_off_t offset);
169typedef xf_vfs_ssize_t (*xf_vfs_pread_op_t) ( int fd, void *dst, size_t size, xf_vfs_off_t offset);
170typedef xf_vfs_ssize_t (*xf_vfs_pwrite_ctx_op_t) (void *ctx, int fd, const void *src, size_t size, xf_vfs_off_t offset);
171typedef xf_vfs_ssize_t (*xf_vfs_pwrite_op_t) ( int fd, const void *src, size_t size, xf_vfs_off_t offset);
172typedef int (*xf_vfs_open_ctx_op_t) (void *ctx, const char *path, int flags, int mode);
173typedef int (*xf_vfs_open_op_t) ( const char *path, int flags, int mode);
174typedef int (*xf_vfs_close_ctx_op_t) (void *ctx, int fd);
175typedef int (*xf_vfs_close_op_t) ( int fd);
176typedef int (*xf_vfs_fstat_ctx_op_t) (void *ctx, int fd, xf_vfs_stat_t *st);
177typedef int (*xf_vfs_fstat_op_t) ( int fd, xf_vfs_stat_t *st);
178typedef int (*xf_vfs_fcntl_ctx_op_t) (void *ctx, int fd, int cmd, int arg);
179typedef int (*xf_vfs_fcntl_op_t) ( int fd, int cmd, int arg);
180typedef int (*xf_vfs_ioctl_ctx_op_t) (void *ctx, int fd, int cmd, va_list args);
181typedef int (*xf_vfs_ioctl_op_t) ( int fd, int cmd, va_list args);
182typedef int (*xf_vfs_fsync_ctx_op_t) (void *ctx, int fd);
183typedef int (*xf_vfs_fsync_op_t) ( int fd);
188typedef struct {
189 union {
192 };
193 union {
196 };
197 union {
200 };
201 union {
204 };
205 union {
208 };
209 union {
212 };
213 union {
216 };
217 union {
220 };
221 union {
224 };
225 union {
228 };
229 union {
232 };
233
234#if XF_VFS_SUPPORT_DIR_IS_ENABLE
235 const xf_vfs_dir_ops_t *const dir;
236#endif
237
238#if XF_VFS_SUPPORT_SELECT_IS_ENABLE || defined __DOXYGEN__
240#endif
241
243
244/* *INDENT-ON* */
245
246/* ==================== [Global Prototypes] ================================= */
247
277xf_err_t xf_vfs_register_fs(const char *base_path, const xf_vfs_fs_ops_t *vfs, int flags, void *ctx);
278
283xf_err_t xf_vfs_register_fs_with_id(const xf_vfs_fs_ops_t *vfs, int flags, void *ctx, xf_vfs_id_t *id);
284
288xf_err_t xf_vfs_unregister_fs(const char *base_path);
289
294
295/* ==================== [Macros] ============================================ */
296
302#ifdef __cplusplus
303} /* extern "C" */
304#endif
305
306#endif /* __XF_VFS_OPS_H__ */
int32_t xf_err_t
整形错误类型。 错误码具体值见 xf_err_code_t.
Definition xf_err.h:69
int(* xf_vfs_fsync_op_t)(int fd)
Definition xf_vfs_ops.h:183
int(* xf_vfs_fstat_op_t)(int fd, xf_vfs_stat_t *st)
Definition xf_vfs_ops.h:177
xf_vfs_ssize_t(* xf_vfs_read_ctx_op_t)(void *ctx, int fd, void *dst, size_t size)
Definition xf_vfs_ops.h:166
int(* xf_vfs_rename_ctx_op_t)(void *ctx, const char *src, const char *dst)
Definition xf_vfs_ops.h:60
int(* xf_vfs_truncate_ctx_op_t)(void *ctx, const char *path, xf_vfs_off_t length)
Definition xf_vfs_ops.h:80
long(* xf_vfs_telldir_ctx_op_t)(void *ctx, xf_vfs_dir_t *pdir)
Definition xf_vfs_ops.h:68
int(* xf_vfs_ioctl_ctx_op_t)(void *ctx, int fd, int cmd, va_list args)
Definition xf_vfs_ops.h:180
int(* xf_vfs_rmdir_ctx_op_t)(void *ctx, const char *name)
Definition xf_vfs_ops.h:76
int(* xf_vfs_fcntl_ctx_op_t)(void *ctx, int fd, int cmd, int arg)
Definition xf_vfs_ops.h:178
int(* xf_vfs_unlink_op_t)(const char *path)
Definition xf_vfs_ops.h:59
int(* xf_vfs_ftruncate_ctx_op_t)(void *ctx, int fd, xf_vfs_off_t length)
Definition xf_vfs_ops.h:82
int(* xf_vfs_unlink_ctx_op_t)(void *ctx, const char *path)
Definition xf_vfs_ops.h:58
int(* xf_vfs_utime_op_t)(const char *path, const xf_vfs_utimbuf_t *times)
Definition xf_vfs_ops.h:85
int(* xf_vfs_link_ctx_op_t)(void *ctx, const char *n1, const char *n2)
Definition xf_vfs_ops.h:56
xf_vfs_ssize_t(* xf_vfs_pread_op_t)(int fd, void *dst, size_t size, xf_vfs_off_t offset)
Definition xf_vfs_ops.h:169
int(* xf_vfs_open_ctx_op_t)(void *ctx, const char *path, int flags, int mode)
Definition xf_vfs_ops.h:172
xf_vfs_dir_t *(* xf_vfs_opendir_op_t)(const char *name)
Definition xf_vfs_ops.h:63
int(* xf_vfs_fstat_ctx_op_t)(void *ctx, int fd, xf_vfs_stat_t *st)
Definition xf_vfs_ops.h:176
int(* xf_vfs_ftruncate_op_t)(int fd, xf_vfs_off_t length)
Definition xf_vfs_ops.h:83
int xf_vfs_id_t
int(* xf_vfs_readdir_r_ctx_op_t)(void *ctx, xf_vfs_dir_t *pdir, xf_vfs_dirent_t *entry, xf_vfs_dirent_t **out)
Definition xf_vfs_ops.h:66
int(* xf_vfs_open_op_t)(const char *path, int flags, int mode)
Definition xf_vfs_ops.h:173
int(* xf_vfs_close_op_t)(int fd)
Definition xf_vfs_ops.h:175
int(* xf_vfs_access_op_t)(const char *path, int amode)
Definition xf_vfs_ops.h:79
int(* xf_vfs_rmdir_op_t)(const char *name)
Definition xf_vfs_ops.h:77
int(* xf_vfs_rename_op_t)(const char *src, const char *dst)
Definition xf_vfs_ops.h:61
xf_err_t xf_vfs_unregister_fs(const char *base_path)
Definition xf_vfs.c:283
xf_err_t xf_vfs_register_fs_with_id(const xf_vfs_fs_ops_t *vfs, int flags, void *ctx, xf_vfs_id_t *id)
Definition xf_vfs.c:220
xf_vfs_ssize_t(* xf_vfs_write_op_t)(int fd, const void *data, size_t size)
Definition xf_vfs_ops.h:163
xf_vfs_off_t(* xf_vfs_lseek_ctx_op_t)(void *ctx, int fd, xf_vfs_off_t size, int mode)
Definition xf_vfs_ops.h:164
int(* xf_vfs_mkdir_op_t)(const char *name, xf_vfs_mode_t mode)
Definition xf_vfs_ops.h:75
xf_vfs_ssize_t(* xf_vfs_pwrite_op_t)(int fd, const void *src, size_t size, xf_vfs_off_t offset)
Definition xf_vfs_ops.h:171
int(* xf_vfs_closedir_op_t)(xf_vfs_dir_t *pdir)
Definition xf_vfs_ops.h:73
int(* xf_vfs_stat_op_t)(const char *path, xf_vfs_stat_t *st)
Definition xf_vfs_ops.h:55
void(* xf_vfs_seekdir_ctx_op_t)(void *ctx, xf_vfs_dir_t *pdir, long offset)
Definition xf_vfs_ops.h:70
xf_err_t xf_vfs_unregister_fs_with_id(xf_vfs_id_t id)
Definition xf_vfs.c:262
xf_vfs_dir_t *(* xf_vfs_opendir_ctx_op_t)(void *ctx, const char *name)
Definition xf_vfs_ops.h:62
void(* xf_vfs_seekdir_op_t)(xf_vfs_dir_t *pdir, long offset)
Definition xf_vfs_ops.h:71
int(* xf_vfs_access_ctx_op_t)(void *ctx, const char *path, int amode)
Definition xf_vfs_ops.h:78
int(* xf_vfs_close_ctx_op_t)(void *ctx, int fd)
Definition xf_vfs_ops.h:174
xf_vfs_ssize_t(* xf_vfs_pread_ctx_op_t)(void *ctx, int fd, void *dst, size_t size, xf_vfs_off_t offset)
Definition xf_vfs_ops.h:168
xf_vfs_ssize_t(* xf_vfs_read_op_t)(int fd, void *dst, size_t size)
Definition xf_vfs_ops.h:167
xf_vfs_off_t(* xf_vfs_lseek_op_t)(int fd, xf_vfs_off_t size, int mode)
Definition xf_vfs_ops.h:165
int(* xf_vfs_mkdir_ctx_op_t)(void *ctx, const char *name, xf_vfs_mode_t mode)
Definition xf_vfs_ops.h:74
xf_vfs_ssize_t(* xf_vfs_write_ctx_op_t)(void *ctx, int fd, const void *data, size_t size)
Definition xf_vfs_ops.h:162
int(* xf_vfs_truncate_op_t)(const char *path, xf_vfs_off_t length)
Definition xf_vfs_ops.h:81
xf_err_t xf_vfs_register_fs(const char *base_path, const xf_vfs_fs_ops_t *vfs, int flags, void *ctx)
Definition xf_vfs.c:117
xf_vfs_dirent_t *(* xf_vfs_readdir_op_t)(xf_vfs_dir_t *pdir)
Definition xf_vfs_ops.h:65
int(* xf_vfs_closedir_ctx_op_t)(void *ctx, xf_vfs_dir_t *pdir)
Definition xf_vfs_ops.h:72
int(* xf_vfs_ioctl_op_t)(int fd, int cmd, va_list args)
Definition xf_vfs_ops.h:181
xf_vfs_dirent_t *(* xf_vfs_readdir_ctx_op_t)(void *ctx, xf_vfs_dir_t *pdir)
Definition xf_vfs_ops.h:64
int(* xf_vfs_fcntl_op_t)(int fd, int cmd, int arg)
Definition xf_vfs_ops.h:179
int(* xf_vfs_link_op_t)(const char *n1, const char *n2)
Definition xf_vfs_ops.h:57
int(* xf_vfs_utime_ctx_op_t)(void *ctx, const char *path, const xf_vfs_utimbuf_t *times)
Definition xf_vfs_ops.h:84
xf_vfs_ssize_t(* xf_vfs_pwrite_ctx_op_t)(void *ctx, int fd, const void *src, size_t size, xf_vfs_off_t offset)
Definition xf_vfs_ops.h:170
int(* xf_vfs_stat_ctx_op_t)(void *ctx, const char *path, xf_vfs_stat_t *st)
Definition xf_vfs_ops.h:54
int(* xf_vfs_fsync_ctx_op_t)(void *ctx, int fd)
Definition xf_vfs_ops.h:182
int(* xf_vfs_readdir_r_op_t)(xf_vfs_dir_t *pdir, xf_vfs_dirent_t *entry, xf_vfs_dirent_t **out)
Definition xf_vfs_ops.h:67
long(* xf_vfs_telldir_op_t)(xf_vfs_dir_t *pdir)
Definition xf_vfs_ops.h:69
Struct containing function pointers to directory related functionality.
Definition xf_vfs_ops.h:90
const xf_vfs_access_op_t access
Definition xf_vfs_ops.h:141
const xf_vfs_link_ctx_op_t link_p
Definition xf_vfs_ops.h:96
const xf_vfs_opendir_ctx_op_t opendir_p
Definition xf_vfs_ops.h:108
const xf_vfs_telldir_ctx_op_t telldir_p
Definition xf_vfs_ops.h:120
const xf_vfs_seekdir_op_t seekdir
Definition xf_vfs_ops.h:125
const xf_vfs_rmdir_op_t rmdir
Definition xf_vfs_ops.h:137
const xf_vfs_ftruncate_ctx_op_t ftruncate_p
Definition xf_vfs_ops.h:148
const xf_vfs_rmdir_ctx_op_t rmdir_p
Definition xf_vfs_ops.h:136
const xf_vfs_mkdir_ctx_op_t mkdir_p
Definition xf_vfs_ops.h:132
const xf_vfs_stat_op_t stat
Definition xf_vfs_ops.h:93
const xf_vfs_seekdir_ctx_op_t seekdir_p
Definition xf_vfs_ops.h:124
const xf_vfs_truncate_op_t truncate
Definition xf_vfs_ops.h:145
const xf_vfs_rename_op_t rename
Definition xf_vfs_ops.h:105
const xf_vfs_ftruncate_op_t ftruncate
Definition xf_vfs_ops.h:149
const xf_vfs_closedir_ctx_op_t closedir_p
Definition xf_vfs_ops.h:128
const xf_vfs_utime_op_t utime
Definition xf_vfs_ops.h:153
const xf_vfs_telldir_op_t telldir
Definition xf_vfs_ops.h:121
const xf_vfs_opendir_op_t opendir
Definition xf_vfs_ops.h:109
const xf_vfs_link_op_t link
Definition xf_vfs_ops.h:97
const xf_vfs_access_ctx_op_t access_p
Definition xf_vfs_ops.h:140
const xf_vfs_closedir_op_t closedir
Definition xf_vfs_ops.h:129
const xf_vfs_unlink_op_t unlink
Definition xf_vfs_ops.h:101
const xf_vfs_stat_ctx_op_t stat_p
Definition xf_vfs_ops.h:92
const xf_vfs_mkdir_op_t mkdir
Definition xf_vfs_ops.h:133
const xf_vfs_readdir_ctx_op_t readdir_p
Definition xf_vfs_ops.h:112
const xf_vfs_truncate_ctx_op_t truncate_p
Definition xf_vfs_ops.h:144
const xf_vfs_unlink_ctx_op_t unlink_p
Definition xf_vfs_ops.h:100
const xf_vfs_readdir_r_ctx_op_t readdir_r_p
Definition xf_vfs_ops.h:116
const xf_vfs_readdir_r_op_t readdir_r
Definition xf_vfs_ops.h:117
const xf_vfs_readdir_op_t readdir
Definition xf_vfs_ops.h:113
const xf_vfs_rename_ctx_op_t rename_p
Definition xf_vfs_ops.h:104
const xf_vfs_utime_ctx_op_t utime_p
Definition xf_vfs_ops.h:152
Opaque directory structure
Directory entry structure
Main struct of the minified vfs API, containing basic function pointers as well as pointers to the ot...
Definition xf_vfs_ops.h:188
const xf_vfs_ioctl_op_t ioctl
Definition xf_vfs_ops.h:227
const xf_vfs_pwrite_ctx_op_t pwrite_p
Definition xf_vfs_ops.h:206
const xf_vfs_pread_op_t pread
Definition xf_vfs_ops.h:203
const xf_vfs_select_ops_t *const select
Definition xf_vfs_ops.h:239
const xf_vfs_dir_ops_t *const dir
Definition xf_vfs_ops.h:235
const xf_vfs_ioctl_ctx_op_t ioctl_p
Definition xf_vfs_ops.h:226
const xf_vfs_fstat_ctx_op_t fstat_p
Definition xf_vfs_ops.h:218
const xf_vfs_read_ctx_op_t read_p
Definition xf_vfs_ops.h:198
const xf_vfs_pwrite_op_t pwrite
Definition xf_vfs_ops.h:207
const xf_vfs_read_op_t read
Definition xf_vfs_ops.h:199
const xf_vfs_lseek_ctx_op_t lseek_p
Definition xf_vfs_ops.h:194
const xf_vfs_fsync_ctx_op_t fsync_p
Definition xf_vfs_ops.h:230
const xf_vfs_open_ctx_op_t open_p
Definition xf_vfs_ops.h:210
const xf_vfs_write_op_t write
Definition xf_vfs_ops.h:191
const xf_vfs_fcntl_ctx_op_t fcntl_p
Definition xf_vfs_ops.h:222
const xf_vfs_fcntl_op_t fcntl
Definition xf_vfs_ops.h:223
const xf_vfs_fstat_op_t fstat
Definition xf_vfs_ops.h:219
const xf_vfs_write_ctx_op_t write_p
Definition xf_vfs_ops.h:190
const xf_vfs_fsync_op_t fsync
Definition xf_vfs_ops.h:231
const xf_vfs_close_ctx_op_t close_p
Definition xf_vfs_ops.h:214
const xf_vfs_pread_ctx_op_t pread_p
Definition xf_vfs_ops.h:202
const xf_vfs_lseek_op_t lseek
Definition xf_vfs_ops.h:195
const xf_vfs_close_op_t close
Definition xf_vfs_ops.h:215
const xf_vfs_open_op_t open
Definition xf_vfs_ops.h:211
Struct containing function pointers to select related functionality.
aos_utimbuf 结构描述了文件系统 inode 的 最后访问时间和最后修改时间。
static ex_scan_ctx_t ctx
Definition xf_main.c:69
xf_vfs 模块内部配置总头文件。 确保 xf_vfs_config.h 的所有定义都有默认值。
unsigned long xf_vfs_mode_t
long xf_vfs_off_t
signed int xf_vfs_ssize_t