esp_vfs_t struct VFS definition structure This structure should be filled with pointers to corresponding FS driver functions. VFS component will translate all FDs so that the filesystem implementation sees them starting at zero. The caller sees a global FD which is prefixed with an pre-filesystem-implementation. Some FS implementations expect some state (e.g. pointer to some structure) to be passed in as a first argument. For these implementations, populate the members of this structure which have _p suffix, set flags member to ESP_VFS_FLAG_CONTEXT_PTR and provide the context pointer to esp_vfs_register function. If the implementation doesn't use this extra argument, populate the members without _p suffix and set flags member to ESP_VFS_FLAG_DEFAULT. If the FS driver doesn't provide some of the functions, set corresponding members to NULL.
Syntax
typedef struct
{
int flags ;
union {
ssize_t ( * write_p ) ( void * p , int fd , const void * data , size_t size ) ;
ssize_t ( * write ) ( int fd , const void * data , size_t size ) ;
} ;
union {
off_t ( * lseek_p ) ( void * p , int fd , off_t size , int mode ) ;
off_t ( * lseek ) ( int fd , off_t size , int mode ) ;
} ;
union {
ssize_t ( * read_p ) ( void * ctx , int fd , void * dst , size_t size ) ;
ssize_t ( * read ) ( int fd , void * dst , size_t size ) ;
} ;
union {
ssize_t ( * pread_p ) ( void * ctx , int fd , void * dst , size_t size , off_t offset ) ;
ssize_t ( * pread ) ( int fd , void * dst , size_t size , off_t offset ) ;
} ;
union {
ssize_t ( * pwrite_p ) ( void * ctx , int fd , const void * src , size_t size , off_t offset ) ;
ssize_t ( * pwrite ) ( int fd , const void * src , size_t size , off_t offset ) ;
} ;
union {
int ( * open_p ) ( void * ctx , const char * path , int flags , int mode ) ;
int ( * open ) ( const char * path , int flags , int mode ) ;
} ;
union {
int ( * close_p ) ( void * ctx , int fd ) ;
int ( * close ) ( int fd ) ;
} ;
union {
int ( * fstat_p ) ( void * ctx , int fd , struct stat * st ) ;
int ( * fstat ) ( int fd , struct stat * st ) ;
} ;
#ifdef CONFIG_VFS_SUPPORT_DIR
union {
int ( * stat_p ) ( void * ctx , const char * path , struct stat * st ) ;
int ( * stat ) ( const char * path , struct stat * st ) ;
} ;
union {
int ( * link_p ) ( void * ctx , const char * n1 , const char * n2 ) ;
int ( * link ) ( const char * n1 , const char * n2 ) ;
} ;
union {
int ( * unlink_p ) ( void * ctx , const char * path ) ;
int ( * unlink ) ( const char * path ) ;
} ;
union {
int ( * rename_p ) ( void * ctx , const char * src , const char * dst ) ;
int ( * rename ) ( const char * src , const char * dst ) ;
} ;
union {
DIR * ( * opendir_p ) ( void * ctx , const char * name ) ;
DIR * ( * opendir ) ( const char * name ) ;
} ;
union {
struct dirent * ( * readdir_p ) ( void * ctx , DIR * pdir ) ;
struct dirent * ( * readdir ) ( DIR * pdir ) ;
} ;
union {
int ( * readdir_r_p ) ( void * ctx , DIR * pdir , struct dirent * entry , struct dirent * * out_dirent ) ;
int ( * readdir_r ) ( DIR * pdir , struct dirent * entry , struct dirent * * out_dirent ) ;
} ;
union {
long ( * telldir_p ) ( void * ctx , DIR * pdir ) ;
long ( * telldir ) ( DIR * pdir ) ;
} ;
union {
void ( * seekdir_p ) ( void * ctx , DIR * pdir , long offset ) ;
void ( * seekdir ) ( DIR * pdir , long offset ) ;
} ;
union {
int ( * closedir_p ) ( void * ctx , DIR * pdir ) ;
int ( * closedir ) ( DIR * pdir ) ;
} ;
union {
int ( * mkdir_p ) ( void * ctx , const char * name , mode_t mode ) ;
int ( * mkdir ) ( const char * name , mode_t mode ) ;
} ;
union {
int ( * rmdir_p ) ( void * ctx , const char * name ) ;
int ( * rmdir ) ( const char * name ) ;
} ;
#endif
union {
int ( * fcntl_p ) ( void * ctx , int fd , int cmd , int arg ) ;
int ( * fcntl ) ( int fd , int cmd , int arg ) ;
} ;
union {
int ( * ioctl_p ) ( void * ctx , int fd , int cmd , va_list args ) ;
int ( * ioctl ) ( int fd , int cmd , va_list args ) ;
} ;
union {
int ( * fsync_p ) ( void * ctx , int fd ) ;
int ( * fsync ) ( int fd ) ;
} ;
#ifdef CONFIG_VFS_SUPPORT_DIR
union {
int ( * access_p ) ( void * ctx , const char * path , int amode ) ;
int ( * access ) ( const char * path , int amode ) ;
} ;
union {
int ( * truncate_p ) ( void * ctx , const char * path , off_t length ) ;
int ( * truncate ) ( const char * path , off_t length ) ;
} ;
union {
int ( * ftruncate_p ) ( void * ctx , int fd , off_t length ) ;
int ( * ftruncate ) ( int fd , off_t length ) ;
} ;
union {
int ( * utime_p ) ( void * ctx , const char * path , const struct utimbuf * times ) ;
int ( * utime ) ( const char * path , const struct utimbuf * times ) ;
} ;
#endif
#ifdef CONFIG_VFS_SUPPORT_TERMIOS
union {
int ( * tcsetattr_p ) ( void * ctx , int fd , int optional_actions , const struct termios * p ) ;
int ( * tcsetattr ) ( int fd , int optional_actions , const struct termios * p ) ;
} ;
union {
int ( * tcgetattr_p ) ( void * ctx , int fd , struct termios * p ) ;
int ( * tcgetattr ) ( int fd , struct termios * p ) ;
} ;
union {
int ( * tcdrain_p ) ( void * ctx , int fd ) ;
int ( * tcdrain ) ( int fd ) ;
} ;
union {
int ( * tcflush_p ) ( void * ctx , int fd , int select ) ;
int ( * tcflush ) ( int fd , int select ) ;
} ;
union {
int ( * tcflow_p ) ( void * ctx , int fd , int action ) ;
int ( * tcflow ) ( int fd , int action ) ;
} ;
union {
pid_t ( * tcgetsid_p ) ( void * ctx , int fd ) ;
pid_t ( * tcgetsid ) ( int fd ) ;
} ;
union {
int ( * tcsendbreak_p ) ( void * ctx , int fd , int duration ) ;
int ( * tcsendbreak ) ( int fd , int duration ) ;
} ;
#endif
#if CONFIG_VFS_SUPPORT_SELECT || defined __DOXYGEN__
esp_err_t ( * start_select ) ( int nfds , fd_set * readfds , fd_set * writefds , fd_set * exceptfds , esp_vfs_select_sem_t sem , void * * end_select_args ) ;
int ( * socket_select ) ( int nfds , fd_set * readfds , fd_set * writefds , fd_set * errorfds , struct timeval * timeout ) ;
void ( * stop_socket_select ) ( void * sem ) ;
void ( * stop_socket_select_isr ) ( void * sem , BaseType_t * woken ) ;
void * ( * get_socket_select_semaphore ) ( void ) ;
esp_err_t ( * end_select ) ( void * end_select_args ) ;
#endif
} esp_vfs_t ;
Fields ESP_VFS_FLAG_CONTEXT_PTR and/or ESP_VFS_FLAG_READONLY_FS or ESP_VFS_FLAG_DEFAULT.
start_select is called for setting up synchronous I/O multiplexing of the desired file descriptors in the given VFS.
int ( * ) ( int nfds , fd_set * readfds , fd_set * writefds , fd_set * errorfds , struct timeval * timeout )
socket select function for socket FDs with the functionality of POSIX select(); this should be set only for the socket VFS.
called by VFS to interrupt the socket_select call when select is activated from a non-socket VFS driver; set only for the socket driver.
stop_socket_select which can be called from ISR; set only for the socket driver.
end_select is called to stop the I/O multiplexing and deinitialize the environment created by start_select for the given VFS.
get_socket_select_semaphore returns semaphore allocated in the socket driver; set only for the socket driver.
Examples esp_vfs_t is referenced by 3 libraries and example projects: