VFS: Implement pread() and pwrite()

Closes https://github.com/espressif/esp-idf/issues/3515
This commit is contained in:
Roland Dobai
2019-07-01 11:08:57 +02:00
committed by bot
parent 1ea68e6093
commit 41062bea99
10 changed files with 307 additions and 0 deletions

View File

@@ -112,6 +112,14 @@ typedef struct
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);
@@ -414,6 +422,35 @@ void esp_vfs_select_triggered_isr(esp_vfs_select_sem_t sem, BaseType_t *woken);
*/
int esp_vfs_poll(struct pollfd *fds, nfds_t nfds, int timeout);
/**
*
* @brief Implements the VFS layer of POSIX pread()
*
* @param fd File descriptor used for read
* @param dst Pointer to the buffer where the output will be written
* @param size Number of bytes to be read
* @param offset Starting offset of the read
*
* @return A positive return value indicates the number of bytes read. -1 is return on failure and errno is
* set accordingly.
*/
ssize_t esp_vfs_pread(int fd, void *dst, size_t size, off_t offset);
/**
*
* @brief Implements the VFS layer of POSIX pwrite()
*
* @param fd File descriptor used for write
* @param src Pointer to the buffer from where the output will be read
* @param size Number of bytes to write
* @param offset Starting offset of the write
*
* @return A positive return value indicates the number of bytes written. -1 is return on failure and errno is
* set accordingly.
*/
ssize_t esp_vfs_pwrite(int fd, const void *src, size_t size, off_t offset);
#ifdef __cplusplus
} // extern "C"
#endif