XFusion API v1.3.0
载入中...
搜索中...
未找到
xf_vfs_types.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_TYPES_H__
28#define __XF_VFS_TYPES_H__
29
30/* ==================== [Includes] ========================================== */
31
33
34#include "xf_vfs_sys__timeval.h"
35#include "xf_vfs_sys_dirent.h"
36#include "xf_vfs_sys_fcntl.h"
37#include "xf_vfs_sys_select.h"
38#include "xf_vfs_sys_stat.h"
39#include "xf_vfs_sys_types.h"
40#include "xf_vfs_sys_unistd.h"
41#include "xf_vfs_sys_utime.h"
42
43#if XF_VFS_SUPPORT_SELECT_IS_ENABLE
44#include "xf_osal.h"
45#endif // XF_VFS_SUPPORT_SELECT_IS_ENABLE
46
47#ifdef __cplusplus
48extern "C" {
49#endif
50
58/* ==================== [Defines] =========================================== */
59
60/* special length value for VFS which is never recognised by open() */
61#define XF_VFS_PATH_PREFIX_LEN_IGNORED (~(size_t)0)
62
66#define XF_VFS_FLAG_DEFAULT (1 << 0)
67
71#define XF_VFS_FLAG_CONTEXT_PTR (1 << 1)
72
76#define XF_VFS_FLAG_READONLY_FS (1 << 2)
77
82#define XF_VFS_FLAG_STATIC (1 << 3)
83
84/* ==================== [Typedefs] ========================================== */
85
86#if XF_VFS_SUPPORT_SELECT_IS_ENABLE
90typedef struct {
92 void *sem;
94#endif // XF_VFS_SUPPORT_SELECT_IS_ENABLE
95
96/*
97 * @brief VFS identificator used for xf_vfs_register_with_id()
98 */
99typedef int xf_vfs_id_t;
100
101/* *INDENT-OFF* */
102
124typedef struct
125{
126 int flags;
127 union {
128 xf_vfs_ssize_t (*write_p)(void* p, int fd, const void * data, size_t size);
129 xf_vfs_ssize_t (*write)(int fd, const void * data, size_t size);
130 };
131 union {
132 xf_vfs_off_t (*lseek_p)(void* p, int fd, xf_vfs_off_t size, int mode);
133 xf_vfs_off_t (*lseek)(int fd, xf_vfs_off_t size, int mode);
134 };
135 union {
136 xf_vfs_ssize_t (*read_p)(void* ctx, int fd, void * dst, size_t size);
137 xf_vfs_ssize_t (*read)(int fd, void * dst, size_t size);
138 };
139 union {
140 xf_vfs_ssize_t (*pread_p)(void *ctx, int fd, void * dst, size_t size, xf_vfs_off_t offset);
141 xf_vfs_ssize_t (*pread)(int fd, void * dst, size_t size, xf_vfs_off_t offset);
142 };
143 union {
144 xf_vfs_ssize_t (*pwrite_p)(void *ctx, int fd, const void *src, size_t size, xf_vfs_off_t offset);
145 xf_vfs_ssize_t (*pwrite)(int fd, const void *src, size_t size, xf_vfs_off_t offset);
146 };
147 union {
148 int (*open_p)(void* ctx, const char * path, int flags, int mode);
149 int (*open)(const char * path, int flags, int mode);
150 };
151 union {
152 int (*close_p)(void* ctx, int fd);
153 int (*close)(int fd);
154 };
155 union {
156 int (*fstat_p)(void* ctx, int fd, xf_vfs_stat_t * st);
157 int (*fstat)(int fd, xf_vfs_stat_t * st);
158 };
159#if XF_VFS_SUPPORT_DIR_IS_ENABLE
160 union {
161 int (*stat_p)(void* ctx, const char * path, xf_vfs_stat_t * st);
162 int (*stat)(const char * path, xf_vfs_stat_t * st);
163 };
164 union {
165 int (*link_p)(void* ctx, const char* n1, const char* n2);
166 int (*link)(const char* n1, const char* n2);
167 };
168 union {
169 int (*unlink_p)(void* ctx, const char *path);
170 int (*unlink)(const char *path);
171 };
172 union {
173 int (*rename_p)(void* ctx, const char *src, const char *dst);
174 int (*rename)(const char *src, const char *dst);
175 };
176 union {
177 xf_vfs_dir_t* (*opendir_p)(void* ctx, const char* name);
178 xf_vfs_dir_t* (*opendir)(const char* name);
179 };
180 union {
181 xf_vfs_dirent_t* (*readdir_p)(void* ctx, xf_vfs_dir_t* pdir);
182 xf_vfs_dirent_t* (*readdir)(xf_vfs_dir_t* pdir);
183 };
184 union {
185 int (*readdir_r_p)(void* ctx, xf_vfs_dir_t* pdir, xf_vfs_dirent_t* entry, xf_vfs_dirent_t** out_dirent);
186 int (*readdir_r)(xf_vfs_dir_t* pdir, xf_vfs_dirent_t* entry, xf_vfs_dirent_t** out_dirent);
187 };
188 union {
189 long (*telldir_p)(void* ctx, xf_vfs_dir_t* pdir);
190 long (*telldir)(xf_vfs_dir_t* pdir);
191 };
192 union {
193 void (*seekdir_p)(void* ctx, xf_vfs_dir_t* pdir, long offset);
194 void (*seekdir)(xf_vfs_dir_t* pdir, long offset);
195 };
196 union {
197 int (*closedir_p)(void* ctx, xf_vfs_dir_t* pdir);
198 int (*closedir)(xf_vfs_dir_t* pdir);
199 };
200 union {
201 int (*mkdir_p)(void* ctx, const char* name, xf_vfs_mode_t mode);
202 int (*mkdir)(const char* name, xf_vfs_mode_t mode);
203 };
204 union {
205 int (*rmdir_p)(void* ctx, const char* name);
206 int (*rmdir)(const char* name);
207 };
208#endif // CONFIG_XF_VFS_SUPPORT_DIR
209 union {
210 int (*fcntl_p)(void* ctx, int fd, int cmd, int arg);
211 int (*fcntl)(int fd, int cmd, int arg);
212 };
213 union {
214 int (*ioctl_p)(void* ctx, int fd, int cmd, va_list args);
215 int (*ioctl)(int fd, int cmd, va_list args);
216 };
217 union {
218 int (*fsync_p)(void* ctx, int fd);
219 int (*fsync)(int fd);
220 };
221#if XF_VFS_SUPPORT_DIR_IS_ENABLE
222 union {
223 int (*access_p)(void* ctx, const char *path, int amode);
224 int (*access)(const char *path, int amode);
225 };
226 union {
227 int (*truncate_p)(void* ctx, const char *path, xf_vfs_off_t length);
228 int (*truncate)(const char *path, xf_vfs_off_t length);
229 };
230 union {
231 int (*ftruncate_p)(void* ctx, int fd, xf_vfs_off_t length);
232 int (*ftruncate)(int fd, xf_vfs_off_t length);
233 };
234 union {
235 int (*utime_p)(void* ctx, const char *path, const xf_vfs_utimbuf_t *times);
236 int (*utime)(const char *path, const xf_vfs_utimbuf_t *times);
237 };
238#endif // CONFIG_XF_VFS_SUPPORT_DIR
239#if XF_VFS_SUPPORT_SELECT_IS_ENABLE || defined __DOXYGEN__
241 xf_err_t (*start_select)(int nfds, xf_fd_set *readfds, xf_fd_set *writefds, xf_fd_set *exceptfds, xf_vfs_select_sem_t sem, void **end_select_args);
243 int (*socket_select)(int nfds, xf_fd_set *readfds, xf_fd_set *writefds, xf_fd_set *errorfds, xf_vfs_timeval_t *timeout);
245 void (*stop_socket_select)(void *sem);
247 void (*stop_socket_select_isr)(void *sem, int *woken);
249 void* (*get_socket_select_semaphore)(void);
251 xf_err_t (*end_select)(void *end_select_args);
252#endif // XF_VFS_SUPPORT_SELECT_IS_ENABLE || defined __DOXYGEN__
253} xf_vfs_t;
254
255/* *INDENT-ON* */
256
257#if XF_VFS_SUPPORT_SELECT_IS_ENABLE
258/* *INDENT-OFF* */
259
260typedef xf_err_t (*xf_vfs_start_select_op_t) (int nfds, xf_fd_set *readfds, xf_fd_set *writefds, xf_fd_set *exceptfds, xf_vfs_select_sem_t sem, void **end_select_args);
261typedef int (*xf_vfs_socket_select_op_t) (int nfds, xf_fd_set *readfds, xf_fd_set *writefds, xf_fd_set *errorfds, xf_vfs_timeval_t *timeout);
262typedef void (*xf_vfs_stop_socket_select_op_t) (void *sem);
263typedef void (*xf_vfs_stop_socket_select_isr_op_t) (void *sem, int *woken);
264typedef void* (*xf_vfs_get_socket_select_semaphore_op_t) (void);
265typedef xf_err_t (*xf_vfs_end_select_op_t) (void *end_select_args);
266
290
291/* *INDENT-ON* */
292#endif // XF_VFS_SUPPORT_SELECT_IS_ENABLE
293
294/* ==================== [Global Prototypes] ================================= */
295
296/* ==================== [Macros] ============================================ */
297
303#ifdef __cplusplus
304} /* extern "C" */
305#endif
306
307#endif /* __XF_VFS_TYPES_H__ */
int32_t xf_err_t
整形错误类型。 错误码具体值见 xf_err_code_t.
Definition xf_err.h:69
xf_err_t(* xf_vfs_start_select_op_t)(int nfds, xf_fd_set *readfds, xf_fd_set *writefds, xf_fd_set *exceptfds, xf_vfs_select_sem_t sem, void **end_select_args)
void *(* xf_vfs_get_socket_select_semaphore_op_t)(void)
int xf_vfs_id_t
int(* xf_vfs_socket_select_op_t)(int nfds, xf_fd_set *readfds, xf_fd_set *writefds, xf_fd_set *errorfds, xf_vfs_timeval_t *timeout)
xf_err_t(* xf_vfs_end_select_op_t)(void *end_select_args)
void(* xf_vfs_stop_socket_select_isr_op_t)(void *sem, int *woken)
void(* xf_vfs_stop_socket_select_op_t)(void *sem)
static xf_osal_semaphore_t sem
Definition xf_main.c:35
Opaque directory structure
Directory entry structure
Struct containing function pointers to select related functionality.
const xf_vfs_get_socket_select_semaphore_op_t get_socket_select_semaphore
const xf_vfs_end_select_op_t end_select
const xf_vfs_stop_socket_select_op_t stop_socket_select
const xf_vfs_stop_socket_select_isr_op_t stop_socket_select_isr
const xf_vfs_socket_select_op_t socket_select
const xf_vfs_start_select_op_t start_select
VFS semaphore type for select()
VFS definition structure
aos_utimbuf 结构描述了文件系统 inode 的 最后访问时间和最后修改时间。
static ex_scan_ctx_t ctx
Definition xf_main.c:69
int ioctl(int fd, unsigned long request,...)
size_t read(int fd, void *buf, size_t count)
int close(int fd)
size_t write(int fd, const void *buf, size_t count)
int open(const char *pathname, int flags)
xf_vfs 模块内部配置总头文件。 确保 xf_vfs_config.h 的所有定义都有默认值。
unsigned long xf_vfs_mode_t
long xf_vfs_off_t
signed int xf_vfs_ssize_t