feat(storage/vfs): Remove usage of context less VFS APIs

This commit is contained in:
Tomáš Rohlínek
2026-03-23 19:50:28 +01:00
parent fea6890b37
commit ece7bf6af6
9 changed files with 178 additions and 160 deletions
+25 -25
View File
@@ -147,7 +147,7 @@ static esp_err_t uart_end_select(void *end_select_args);
#endif // CONFIG_VFS_SUPPORT_SELECT #endif // CONFIG_VFS_SUPPORT_SELECT
static int uart_open(const char *path, int flags, int mode) static int uart_open(__attribute__((unused)) void *ctx, const char *path, int flags, int mode)
{ {
// this is fairly primitive, we should check if file is opened read only, // this is fairly primitive, we should check if file is opened read only,
// and error out if write is requested // and error out if write is requested
@@ -223,7 +223,7 @@ static int uart_rx_char_via_driver(int fd)
return c; return c;
} }
static ssize_t uart_write(int fd, const void * data, size_t size) static ssize_t uart_write(__attribute__((unused)) void *ctx, int fd, const void * data, size_t size)
{ {
assert(fd >= 0 && fd < 3); assert(fd >= 0 && fd < 3);
tx_func_t tx_func = s_ctx[fd]->tx_func; tx_func_t tx_func = s_ctx[fd]->tx_func;
@@ -270,7 +270,7 @@ static void uart_return_char(int fd, int c)
s_ctx[fd]->peek_char = c; s_ctx[fd]->peek_char = c;
} }
static ssize_t uart_read(int fd, void* data, size_t size) static ssize_t uart_read(__attribute__((unused)) void *ctx, int fd, void* data, size_t size)
{ {
assert(fd >= 0 && fd < 3); assert(fd >= 0 && fd < 3);
char *data_c = (char *) data; char *data_c = (char *) data;
@@ -343,7 +343,7 @@ static ssize_t uart_read(int fd, void* data, size_t size)
return -1; return -1;
} }
static int uart_fstat(int fd, struct stat * st) static int uart_fstat(__attribute__((unused)) void *ctx, int fd, struct stat * st)
{ {
assert(fd >= 0 && fd < 3); assert(fd >= 0 && fd < 3);
memset(st, 0, sizeof(*st)); memset(st, 0, sizeof(*st));
@@ -351,13 +351,13 @@ static int uart_fstat(int fd, struct stat * st)
return 0; return 0;
} }
static int uart_close(int fd) static int uart_close(__attribute__((unused)) void *ctx, int fd)
{ {
assert(fd >= 0 && fd < 3); assert(fd >= 0 && fd < 3);
return 0; return 0;
} }
static int uart_fcntl(int fd, int cmd, int arg) static int uart_fcntl(__attribute__((unused)) void *ctx, int fd, int cmd, int arg)
{ {
assert(fd >= 0 && fd < 3); assert(fd >= 0 && fd < 3);
int result = 0; int result = 0;
@@ -378,7 +378,7 @@ static int uart_fcntl(int fd, int cmd, int arg)
#ifdef CONFIG_VFS_SUPPORT_DIR #ifdef CONFIG_VFS_SUPPORT_DIR
static int uart_access(const char *path, int amode) static int uart_access(__attribute__((unused)) void *ctx, const char *path, int amode)
{ {
int ret = -1; int ret = -1;
@@ -401,7 +401,7 @@ static int uart_access(const char *path, int amode)
#endif // CONFIG_VFS_SUPPORT_DIR #endif // CONFIG_VFS_SUPPORT_DIR
static int uart_fsync(int fd) static int uart_fsync(__attribute__((unused)) void *ctx, int fd)
{ {
assert(fd >= 0 && fd < 3); assert(fd >= 0 && fd < 3);
_lock_acquire_recursive(&s_ctx[fd]->write_lock); _lock_acquire_recursive(&s_ctx[fd]->write_lock);
@@ -588,7 +588,7 @@ static esp_err_t uart_end_select(void *end_select_args)
#endif // CONFIG_VFS_SUPPORT_SELECT #endif // CONFIG_VFS_SUPPORT_SELECT
#ifdef CONFIG_VFS_SUPPORT_TERMIOS #ifdef CONFIG_VFS_SUPPORT_TERMIOS
static int uart_tcsetattr(int fd, int optional_actions, const struct termios *p) static int uart_tcsetattr(__attribute__((unused)) void *ctx, int fd, int optional_actions, const struct termios *p)
{ {
if (fd < 0 || fd >= UART_NUM) { if (fd < 0 || fd >= UART_NUM) {
errno = EBADF; errno = EBADF;
@@ -793,7 +793,7 @@ static int uart_tcsetattr(int fd, int optional_actions, const struct termios *p)
return 0; return 0;
} }
static int uart_tcgetattr(int fd, struct termios *p) static int uart_tcgetattr(__attribute__((unused)) void *ctx, int fd, struct termios *p)
{ {
if (fd < 0 || fd >= UART_NUM) { if (fd < 0 || fd >= UART_NUM) {
errno = EBADF; errno = EBADF;
@@ -1002,7 +1002,7 @@ static int uart_tcgetattr(int fd, struct termios *p)
return 0; return 0;
} }
static int uart_tcdrain(int fd) static int uart_tcdrain(__attribute__((unused)) void *ctx, int fd)
{ {
if (fd < 0 || fd >= UART_NUM) { if (fd < 0 || fd >= UART_NUM) {
errno = EBADF; errno = EBADF;
@@ -1017,7 +1017,7 @@ static int uart_tcdrain(int fd)
return 0; return 0;
} }
static int uart_tcflush(int fd, int select) static int uart_tcflush(__attribute__((unused)) void *ctx, int fd, int select)
{ {
if (fd < 0 || fd >= UART_NUM) { if (fd < 0 || fd >= UART_NUM) {
errno = EBADF; errno = EBADF;
@@ -1041,7 +1041,7 @@ static int uart_tcflush(int fd, int select)
#ifdef CONFIG_VFS_SUPPORT_DIR #ifdef CONFIG_VFS_SUPPORT_DIR
static const esp_vfs_dir_ops_t s_vfs_uart_dir = { static const esp_vfs_dir_ops_t s_vfs_uart_dir = {
.access = &uart_access, .access_p = &uart_access,
}; };
#endif // CONFIG_VFS_SUPPORT_DIR #endif // CONFIG_VFS_SUPPORT_DIR
@@ -1054,21 +1054,21 @@ static const esp_vfs_select_ops_t s_vfs_uart_select = {
#ifdef CONFIG_VFS_SUPPORT_TERMIOS #ifdef CONFIG_VFS_SUPPORT_TERMIOS
static const esp_vfs_termios_ops_t s_vfs_uart_termios = { static const esp_vfs_termios_ops_t s_vfs_uart_termios = {
.tcsetattr = &uart_tcsetattr, .tcsetattr_p = &uart_tcsetattr,
.tcgetattr = &uart_tcgetattr, .tcgetattr_p = &uart_tcgetattr,
.tcdrain = &uart_tcdrain, .tcdrain_p = &uart_tcdrain,
.tcflush = &uart_tcflush, .tcflush_p = &uart_tcflush,
}; };
#endif // CONFIG_VFS_SUPPORT_TERMIOS #endif // CONFIG_VFS_SUPPORT_TERMIOS
static const esp_vfs_fs_ops_t s_vfs_uart = { static const esp_vfs_fs_ops_t s_vfs_uart = {
.write = &uart_write, .write_p = &uart_write,
.open = &uart_open, .open_p = &uart_open,
.fstat = &uart_fstat, .fstat_p = &uart_fstat,
.close = &uart_close, .close_p = &uart_close,
.read = &uart_read, .read_p = &uart_read,
.fcntl = &uart_fcntl, .fcntl_p = &uart_fcntl,
.fsync = &uart_fsync, .fsync_p = &uart_fsync,
#ifdef CONFIG_VFS_SUPPORT_DIR #ifdef CONFIG_VFS_SUPPORT_DIR
.dir = &s_vfs_uart_dir, .dir = &s_vfs_uart_dir,
#endif // CONFIG_VFS_SUPPORT_DIR #endif // CONFIG_VFS_SUPPORT_DIR
@@ -1087,7 +1087,7 @@ const esp_vfs_fs_ops_t *esp_vfs_uart_get_vfs(void)
void uart_vfs_dev_register(void) void uart_vfs_dev_register(void)
{ {
ESP_ERROR_CHECK(esp_vfs_register_fs("/dev/uart", &s_vfs_uart, ESP_VFS_FLAG_STATIC, NULL)); ESP_ERROR_CHECK(esp_vfs_register_fs("/dev/uart", &s_vfs_uart, ESP_VFS_FLAG_STATIC | ESP_VFS_FLAG_CONTEXT_PTR, NULL));
} }
int uart_vfs_dev_port_set_rx_line_endings(int uart_num, esp_line_endings_t mode) int uart_vfs_dev_port_set_rx_line_endings(int uart_num, esp_line_endings_t mode)
@@ -138,7 +138,7 @@ static esp_err_t usb_serial_jtag_end_select(void *end_select_args);
#endif // CONFIG_VFS_SUPPORT_SELECT #endif // CONFIG_VFS_SUPPORT_SELECT
static int usb_serial_jtag_open(const char * path, int flags, int mode) static int usb_serial_jtag_open(__attribute__((unused)) void *ctx, const char * path, int flags, int mode)
{ {
s_ctx.non_blocking = ((flags & O_NONBLOCK) == O_NONBLOCK); s_ctx.non_blocking = ((flags & O_NONBLOCK) == O_NONBLOCK);
return USJ_LOCAL_FD; return USJ_LOCAL_FD;
@@ -179,7 +179,7 @@ static int usb_serial_jtag_rx_char_no_driver(int fd)
return c; return c;
} }
static ssize_t usb_serial_jtag_write(int fd, const void * data, size_t size) static ssize_t usb_serial_jtag_write(__attribute__((unused)) void *ctx, int fd, const void * data, size_t size)
{ {
if (!usb_serial_jtag_is_connected()) { if (!usb_serial_jtag_is_connected()) {
// TODO: IDF-14303 // TODO: IDF-14303
@@ -227,7 +227,7 @@ static void usb_serial_jtag_return_char(int fd, int c)
s_ctx.peek_char = c; s_ctx.peek_char = c;
} }
static ssize_t usb_serial_jtag_read(int fd, void* data, size_t size) static ssize_t usb_serial_jtag_read(__attribute__((unused)) void *ctx, int fd, void* data, size_t size)
{ {
if (!usb_serial_jtag_is_connected()) { if (!usb_serial_jtag_is_connected()) {
// TODO: IDF-14303 // TODO: IDF-14303
@@ -305,19 +305,19 @@ static ssize_t usb_serial_jtag_read(int fd, void* data, size_t size)
return -1; return -1;
} }
static int usb_serial_jtag_fstat(int fd, struct stat * st) static int usb_serial_jtag_fstat(__attribute__((unused)) void *ctx, int fd, struct stat * st)
{ {
memset(st, 0, sizeof(*st)); memset(st, 0, sizeof(*st));
st->st_mode = S_IFCHR; st->st_mode = S_IFCHR;
return 0; return 0;
} }
static int usb_serial_jtag_close(int fd) static int usb_serial_jtag_close(__attribute__((unused)) void *ctx, int fd)
{ {
return 0; return 0;
} }
static int usb_serial_jtag_fcntl(int fd, int cmd, int arg) static int usb_serial_jtag_fcntl(__attribute__((unused)) void *ctx, int fd, int cmd, int arg)
{ {
int result = 0; int result = 0;
if (cmd == F_GETFL) { if (cmd == F_GETFL) {
@@ -354,7 +354,7 @@ static int usb_serial_jtag_wait_tx_done_no_driver(int fd)
return EIO; return EIO;
} }
static int usb_serial_jtag_fsync(int fd) static int usb_serial_jtag_fsync(__attribute__((unused)) void *ctx, int fd)
{ {
if (!usb_serial_jtag_is_connected()) { if (!usb_serial_jtag_is_connected()) {
// TODO: IDF-14303 // TODO: IDF-14303
@@ -549,7 +549,7 @@ static esp_err_t usb_serial_jtag_end_select(void *end_select_args)
#endif // CONFIG_VFS_SUPPORT_SELECT #endif // CONFIG_VFS_SUPPORT_SELECT
#ifdef CONFIG_VFS_SUPPORT_TERMIOS #ifdef CONFIG_VFS_SUPPORT_TERMIOS
static int usb_serial_jtag_tcsetattr(int fd, int optional_actions, const struct termios *p) static int usb_serial_jtag_tcsetattr(__attribute__((unused)) void *ctx, int fd, int optional_actions, const struct termios *p)
{ {
if (p == NULL) { if (p == NULL) {
errno = EINVAL; errno = EINVAL;
@@ -561,7 +561,7 @@ static int usb_serial_jtag_tcsetattr(int fd, int optional_actions, const struct
// nothing to do // nothing to do
break; break;
case TCSADRAIN: case TCSADRAIN:
usb_serial_jtag_fsync(fd); usb_serial_jtag_fsync(ctx, fd);
break; break;
case TCSAFLUSH: case TCSAFLUSH:
// Not applicable. // Not applicable.
@@ -581,7 +581,7 @@ static int usb_serial_jtag_tcsetattr(int fd, int optional_actions, const struct
return 0; return 0;
} }
static int usb_serial_jtag_tcgetattr(int fd, struct termios *p) static int usb_serial_jtag_tcgetattr(__attribute__((unused)) void *ctx, int fd, struct termios *p)
{ {
if (p == NULL) { if (p == NULL) {
errno = EINVAL; errno = EINVAL;
@@ -606,13 +606,13 @@ static int usb_serial_jtag_tcgetattr(int fd, struct termios *p)
return 0; return 0;
} }
static int usb_serial_jtag_tcdrain(int fd) static int usb_serial_jtag_tcdrain(__attribute__((unused)) void *ctx, int fd)
{ {
usb_serial_jtag_fsync(fd); usb_serial_jtag_fsync(ctx, fd);
return 0; return 0;
} }
static int usb_serial_jtag_tcflush(int fd, int select) static int usb_serial_jtag_tcflush(__attribute__((unused)) void *ctx, int fd, int select)
{ {
//Flushing is not supported. //Flushing is not supported.
errno = EINVAL; errno = EINVAL;
@@ -638,21 +638,21 @@ static const esp_vfs_select_ops_t s_vfs_jtag_select = {
#endif // CONFIG_VFS_SUPPORT_SELECT #endif // CONFIG_VFS_SUPPORT_SELECT
#ifdef CONFIG_VFS_SUPPORT_TERMIOS #ifdef CONFIG_VFS_SUPPORT_TERMIOS
static const esp_vfs_termios_ops_t s_vfs_jtag_termios = { static const esp_vfs_termios_ops_t s_vfs_jtag_termios = {
.tcsetattr = &usb_serial_jtag_tcsetattr, .tcsetattr_p = &usb_serial_jtag_tcsetattr,
.tcgetattr = &usb_serial_jtag_tcgetattr, .tcgetattr_p = &usb_serial_jtag_tcgetattr,
.tcdrain = &usb_serial_jtag_tcdrain, .tcdrain_p = &usb_serial_jtag_tcdrain,
.tcflush = &usb_serial_jtag_tcflush, .tcflush_p = &usb_serial_jtag_tcflush,
}; };
#endif // CONFIG_VFS_SUPPORT_TERMIOS #endif // CONFIG_VFS_SUPPORT_TERMIOS
static const esp_vfs_fs_ops_t s_vfs_jtag = { static const esp_vfs_fs_ops_t s_vfs_jtag = {
.write = &usb_serial_jtag_write, .write_p = &usb_serial_jtag_write,
.open = &usb_serial_jtag_open, .open_p = &usb_serial_jtag_open,
.fstat = &usb_serial_jtag_fstat, .fstat_p = &usb_serial_jtag_fstat,
.close = &usb_serial_jtag_close, .close_p = &usb_serial_jtag_close,
.read = &usb_serial_jtag_read, .read_p = &usb_serial_jtag_read,
.fcntl = &usb_serial_jtag_fcntl, .fcntl_p = &usb_serial_jtag_fcntl,
.fsync = &usb_serial_jtag_fsync, .fsync_p = &usb_serial_jtag_fsync,
#ifdef CONFIG_VFS_SUPPORT_SELECT #ifdef CONFIG_VFS_SUPPORT_SELECT
.select = &s_vfs_jtag_select, .select = &s_vfs_jtag_select,
@@ -671,7 +671,7 @@ const esp_vfs_fs_ops_t* esp_vfs_usb_serial_jtag_get_vfs(void)
esp_err_t usb_serial_jtag_vfs_register(void) esp_err_t usb_serial_jtag_vfs_register(void)
{ {
// "/dev/usb_serial_jtag" unfortunately is too long for vfs // "/dev/usb_serial_jtag" unfortunately is too long for vfs
return esp_vfs_register_fs("/dev/usbserjtag", &s_vfs_jtag, ESP_VFS_FLAG_STATIC, NULL); return esp_vfs_register_fs("/dev/usbserjtag", &s_vfs_jtag, ESP_VFS_FLAG_STATIC | ESP_VFS_FLAG_CONTEXT_PTR, NULL);
} }
#if CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG #if CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG
@@ -686,7 +686,7 @@ ESP_SYSTEM_INIT_FN(init_vfs_usj, CORE, BIT(0), 111)
ESP_SYSTEM_INIT_FN(init_vfs_usj_sec, CORE, BIT(0), 112) ESP_SYSTEM_INIT_FN(init_vfs_usj_sec, CORE, BIT(0), 112)
{ {
// "/dev/seccondary_usb_serial_jtag" unfortunately is too long for vfs // "/dev/seccondary_usb_serial_jtag" unfortunately is too long for vfs
esp_vfs_register_fs("/dev/secondary", &s_vfs_jtag, ESP_VFS_FLAG_STATIC, NULL); esp_vfs_register_fs("/dev/secondary", &s_vfs_jtag, ESP_VFS_FLAG_STATIC | ESP_VFS_FLAG_CONTEXT_PTR, NULL);
return ESP_OK; return ESP_OK;
} }
#endif #endif
+14 -14
View File
@@ -259,7 +259,7 @@ esp_err_t esp_vfs_l2tap_eth_filter_frame(l2tap_iodriver_handle driver_handle, vo
} }
/* ====================== vfs ====================== */ /* ====================== vfs ====================== */
static int l2tap_open(const char *path, int flags, int mode) static int l2tap_open(__attribute__((unused)) void *ctx, const char *path, int flags, int mode)
{ {
int fd; int fd;
@@ -307,7 +307,7 @@ static int l2tap_tx_esp_err_to_errno(esp_err_t esp_err)
} }
} }
static ssize_t l2tap_write(int fd, const void *data, size_t size) static ssize_t l2tap_write(__attribute__((unused)) void *ctx, int fd, const void *data, size_t size)
{ {
void *eth_buff; void *eth_buff;
l2tap_extended_buff_t *ext_buff; l2tap_extended_buff_t *ext_buff;
@@ -402,7 +402,7 @@ static int l2tap_rx_esp_err_to_errno(esp_err_t esp_err)
} }
} }
static ssize_t l2tap_read(int fd, void *data, size_t size) static ssize_t l2tap_read(__attribute__((unused)) void *ctx, int fd, void *data, size_t size)
{ {
// fd might be in process of opening/closing (close was already called but preempted) // fd might be in process of opening/closing (close was already called but preempted)
if (atomic_load(&s_l2tap_sockets[fd].state) != L2TAP_SOCK_STATE_OPENED) { if (atomic_load(&s_l2tap_sockets[fd].state) != L2TAP_SOCK_STATE_OPENED) {
@@ -441,7 +441,7 @@ static ssize_t l2tap_read(int fd, void *data, size_t size)
return actual_size; return actual_size;
} }
void l2tap_clean_task(void *task_param) static void l2tap_clean_task(void *task_param)
{ {
l2tap_context_t *l2tap_socket = (l2tap_context_t *)task_param; l2tap_context_t *l2tap_socket = (l2tap_context_t *)task_param;
@@ -465,7 +465,7 @@ void l2tap_clean_task(void *task_param)
vTaskDelete(NULL); vTaskDelete(NULL);
} }
static int l2tap_close(int fd) static int l2tap_close(__attribute__((unused)) void *ctx, int fd)
{ {
if (atomic_load(&s_l2tap_sockets[fd].state) != L2TAP_SOCK_STATE_OPENED) { if (atomic_load(&s_l2tap_sockets[fd].state) != L2TAP_SOCK_STATE_OPENED) {
// not valid opened fd // not valid opened fd
@@ -503,7 +503,7 @@ static bool netif_driver_matches(esp_netif_t *netif, void* driver)
return esp_netif_get_io_driver(netif) == driver; return esp_netif_get_io_driver(netif) == driver;
} }
static int l2tap_ioctl(int fd, int cmd, va_list args) static int l2tap_ioctl(__attribute__((unused)) void *ctx, int fd, int cmd, va_list args)
{ {
esp_netif_t *esp_netif; esp_netif_t *esp_netif;
switch (cmd) { switch (cmd) {
@@ -608,7 +608,7 @@ static void l2tap_set_nonblocking(l2tap_context_t *l2tap_socket, bool nonblock)
l2tap_exit_critical(); l2tap_exit_critical();
} }
static int l2tap_fcntl(int fd, int cmd, int arg) static int l2tap_fcntl(__attribute__((unused)) void *ctx, int fd, int cmd, int arg)
{ {
int result = 0; int result = 0;
if (cmd == F_GETFL) { if (cmd == F_GETFL) {
@@ -801,12 +801,12 @@ static const esp_vfs_select_ops_t s_vfs_l2tap_select = {
#endif //CONFIG_VFS_SUPPORT_SELECT #endif //CONFIG_VFS_SUPPORT_SELECT
static const esp_vfs_fs_ops_t s_vfs_l2tap = { static const esp_vfs_fs_ops_t s_vfs_l2tap = {
.write = &l2tap_write, .write_p = &l2tap_write,
.open = &l2tap_open, .open_p = &l2tap_open,
.close = &l2tap_close, .close_p = &l2tap_close,
.read = &l2tap_read, .read_p = &l2tap_read,
.fcntl = &l2tap_fcntl, .fcntl_p = &l2tap_fcntl,
.ioctl = &l2tap_ioctl, .ioctl_p = &l2tap_ioctl,
#ifdef CONFIG_VFS_SUPPORT_SELECT #ifdef CONFIG_VFS_SUPPORT_SELECT
.select = &s_vfs_l2tap_select, .select = &s_vfs_l2tap_select,
#endif // CONFIG_VFS_SUPPORT_SELECT #endif // CONFIG_VFS_SUPPORT_SELECT
@@ -823,7 +823,7 @@ esp_err_t esp_vfs_l2tap_intf_register(l2tap_vfs_config_t *config)
ESP_RETURN_ON_FALSE(!s_is_registered, ESP_ERR_INVALID_STATE, TAG, "vfs is already registered"); ESP_RETURN_ON_FALSE(!s_is_registered, ESP_ERR_INVALID_STATE, TAG, "vfs is already registered");
s_is_registered = true; s_is_registered = true;
ESP_RETURN_ON_ERROR(esp_vfs_register_fs(config->base_path, &s_vfs_l2tap, ESP_VFS_FLAG_STATIC, NULL), TAG, "vfs register error"); ESP_RETURN_ON_ERROR(esp_vfs_register_fs(config->base_path, &s_vfs_l2tap, ESP_VFS_FLAG_STATIC | ESP_VFS_FLAG_CONTEXT_PTR, NULL), TAG, "vfs register error");
return ESP_OK; return ESP_OK;
} }
+25 -25
View File
@@ -49,7 +49,7 @@ static vfs_console_context_t vfs_console = {0};
static size_t s_open_count = 0; static size_t s_open_count = 0;
int console_open(const char * path, int flags, int mode) int console_open(__attribute__((unused)) void *ctx, const char * path, int flags, int mode)
{ {
if (s_open_count > 0) { if (s_open_count > 0) {
// Underlying fd is already open, so just increment the open count // Underlying fd is already open, so just increment the open count
@@ -79,7 +79,7 @@ int console_open(const char * path, int flags, int mode)
return 0; return 0;
} }
ssize_t console_write(int fd, const void *data, size_t size) ssize_t console_write(__attribute__((unused)) void *ctx, int fd, const void *data, size_t size)
{ {
write(vfs_console.fd_primary, data, size); write(vfs_console.fd_primary, data, size);
#if CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG #if CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG
@@ -88,12 +88,12 @@ ssize_t console_write(int fd, const void *data, size_t size)
return size; return size;
} }
int console_fstat(int fd, struct stat * st) int console_fstat(__attribute__((unused)) void *ctx, int fd, struct stat * st)
{ {
return fstat(vfs_console.fd_primary, st); return fstat(vfs_console.fd_primary, st);
} }
int console_close(int fd) int console_close(__attribute__((unused)) void *ctx, int fd)
{ {
if (s_open_count == 0) { if (s_open_count == 0) {
errno = EBADF; errno = EBADF;
@@ -115,17 +115,17 @@ int console_close(int fd)
return 0; return 0;
} }
ssize_t console_read(int fd, void * dst, size_t size) ssize_t console_read(__attribute__((unused)) void *ctx, int fd, void * dst, size_t size)
{ {
return read(vfs_console.fd_primary, dst, size); return read(vfs_console.fd_primary, dst, size);
} }
int console_fcntl(int fd, int cmd, int arg) int console_fcntl(__attribute__((unused)) void *ctx, int fd, int cmd, int arg)
{ {
return fcntl(vfs_console.fd_primary, cmd, arg); return fcntl(vfs_console.fd_primary, cmd, arg);
} }
int console_fsync(int fd) int console_fsync(__attribute__((unused)) void *ctx, int fd)
{ {
const int ret_val = fsync(vfs_console.fd_primary); const int ret_val = fsync(vfs_console.fd_primary);
#if CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG #if CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG
@@ -135,7 +135,7 @@ int console_fsync(int fd)
} }
#ifdef CONFIG_VFS_SUPPORT_DIR #ifdef CONFIG_VFS_SUPPORT_DIR
int console_access(const char *path, int amode) int console_access(__attribute__((unused)) void *ctx, const char *path, int amode)
{ {
// currently only UART support DIR. // currently only UART support DIR.
return access("/dev/uart/"STRINGIFY(CONFIG_ESP_CONSOLE_UART_NUM), amode); return access("/dev/uart/"STRINGIFY(CONFIG_ESP_CONSOLE_UART_NUM), amode);
@@ -168,22 +168,22 @@ esp_err_t console_end_select(void *end_select_args)
#ifdef CONFIG_VFS_SUPPORT_TERMIOS #ifdef CONFIG_VFS_SUPPORT_TERMIOS
int console_tcsetattr(int fd, int optional_actions, const struct termios *p) int console_tcsetattr(__attribute__((unused)) void *ctx, int fd, int optional_actions, const struct termios *p)
{ {
return tcsetattr(vfs_console.fd_primary, optional_actions, p); return tcsetattr(vfs_console.fd_primary, optional_actions, p);
} }
int console_tcgetattr(int fd, struct termios *p) int console_tcgetattr(__attribute__((unused)) void *ctx, int fd, struct termios *p)
{ {
return tcgetattr(vfs_console.fd_primary, p); return tcgetattr(vfs_console.fd_primary, p);
} }
int console_tcdrain(int fd) int console_tcdrain(__attribute__((unused)) void *ctx, int fd)
{ {
return tcdrain(vfs_console.fd_primary); return tcdrain(vfs_console.fd_primary);
} }
int console_tcflush(int fd, int select) int console_tcflush(__attribute__((unused)) void *ctx, int fd, int select)
{ {
return tcflush(vfs_console.fd_primary, select); return tcflush(vfs_console.fd_primary, select);
} }
@@ -191,7 +191,7 @@ int console_tcflush(int fd, int select)
#ifdef CONFIG_VFS_SUPPORT_DIR #ifdef CONFIG_VFS_SUPPORT_DIR
static const esp_vfs_dir_ops_t s_vfs_console_dir = { static const esp_vfs_dir_ops_t s_vfs_console_dir = {
.access = &console_access, .access_p = &console_access,
}; };
#endif // CONFIG_VFS_SUPPORT_DIR #endif // CONFIG_VFS_SUPPORT_DIR
@@ -204,21 +204,21 @@ static const esp_vfs_select_ops_t s_vfs_console_select = {
#ifdef CONFIG_VFS_SUPPORT_TERMIOS #ifdef CONFIG_VFS_SUPPORT_TERMIOS
static const esp_vfs_termios_ops_t s_vfs_console_termios = { static const esp_vfs_termios_ops_t s_vfs_console_termios = {
.tcsetattr = &console_tcsetattr, .tcsetattr_p = &console_tcsetattr,
.tcgetattr = &console_tcgetattr, .tcgetattr_p = &console_tcgetattr,
.tcdrain = &console_tcdrain, .tcdrain_p = &console_tcdrain,
.tcflush = &console_tcflush, .tcflush_p = &console_tcflush,
}; };
#endif // CONFIG_VFS_SUPPORT_TERMIOS #endif // CONFIG_VFS_SUPPORT_TERMIOS
static const esp_vfs_fs_ops_t s_vfs_console = { static const esp_vfs_fs_ops_t s_vfs_console = {
.write = &console_write, .write_p = &console_write,
.open = &console_open, .open_p = &console_open,
.fstat = &console_fstat, .fstat_p = &console_fstat,
.close = &console_close, .close_p = &console_close,
.read = &console_read, .read_p = &console_read,
.fcntl = &console_fcntl, .fcntl_p = &console_fcntl,
.fsync = &console_fsync, .fsync_p = &console_fsync,
#ifdef CONFIG_VFS_SUPPORT_DIR #ifdef CONFIG_VFS_SUPPORT_DIR
.dir = &s_vfs_console_dir, .dir = &s_vfs_console_dir,
@@ -235,7 +235,7 @@ static const esp_vfs_fs_ops_t s_vfs_console = {
static esp_err_t esp_vfs_dev_console_register(void) static esp_err_t esp_vfs_dev_console_register(void)
{ {
return esp_vfs_register_fs(ESP_VFS_DEV_CONSOLE, &s_vfs_console, ESP_VFS_FLAG_STATIC, NULL); return esp_vfs_register_fs(ESP_VFS_DEV_CONSOLE, &s_vfs_console, ESP_VFS_FLAG_STATIC | ESP_VFS_FLAG_CONTEXT_PTR, NULL);
} }
esp_err_t esp_stdio_register(void) esp_err_t esp_stdio_register(void)
+15 -15
View File
@@ -78,7 +78,7 @@ static esp_err_t cdcacm_end_select(void *end_select_args);
#endif // CONFIG_VFS_SUPPORT_SELECT #endif // CONFIG_VFS_SUPPORT_SELECT
static ssize_t cdcacm_write(int fd, const void *data, size_t size) static ssize_t cdcacm_write(__attribute__((unused)) void *ctx, int fd, const void *data, size_t size)
{ {
assert(fd == 0); assert(fd == 0);
const char *cdata = (const char *)data; const char *cdata = (const char *)data;
@@ -101,7 +101,7 @@ static ssize_t cdcacm_write(int fd, const void *data, size_t size)
return size; return size;
} }
static int cdcacm_fsync(int fd) static int cdcacm_fsync(__attribute__((unused)) void *ctx, int fd)
{ {
assert(fd == 0); assert(fd == 0);
_lock_acquire_recursive(&s_write_lock); _lock_acquire_recursive(&s_write_lock);
@@ -110,12 +110,12 @@ static int cdcacm_fsync(int fd)
return (written < 0) ? -1 : 0; return (written < 0) ? -1 : 0;
} }
static int cdcacm_open(const char *path, int flags, int mode) static int cdcacm_open(__attribute__((unused)) void *ctx, const char *path, int flags, int mode)
{ {
return USB_CDC_LOCAL_FD; // fd 0 return USB_CDC_LOCAL_FD; // fd 0
} }
static int cdcacm_fstat(int fd, struct stat *st) static int cdcacm_fstat(__attribute__((unused)) void *ctx, int fd, struct stat *st)
{ {
assert(fd == 0); assert(fd == 0);
memset(st, 0, sizeof(*st)); memset(st, 0, sizeof(*st));
@@ -123,7 +123,7 @@ static int cdcacm_fstat(int fd, struct stat *st)
return 0; return 0;
} }
static int cdcacm_close(int fd) static int cdcacm_close(__attribute__((unused)) void *ctx, int fd)
{ {
assert(fd == 0); assert(fd == 0);
return 0; return 0;
@@ -174,7 +174,7 @@ static void cdcacm_return_char(int c)
s_peek_char = c; s_peek_char = c;
} }
static ssize_t cdcacm_read(int fd, void *data, size_t size) static ssize_t cdcacm_read(__attribute__((unused)) void *ctx, int fd, void *data, size_t size)
{ {
assert(fd == USB_CDC_LOCAL_FD); assert(fd == USB_CDC_LOCAL_FD);
char *data_c = (char *) data; char *data_c = (char *) data;
@@ -289,7 +289,7 @@ static int cdcacm_disable_blocking(void)
return 0; return 0;
} }
static int cdcacm_fcntl(int fd, int cmd, int arg) static int cdcacm_fcntl(__attribute__((unused)) void *ctx, int fd, int cmd, int arg)
{ {
assert(fd == 0); assert(fd == 0);
int result; int result;
@@ -502,13 +502,13 @@ static const esp_vfs_select_ops_t s_cdcacm_vfs_select = {
#endif // CONFIG_VFS_SUPPORT_SELECT #endif // CONFIG_VFS_SUPPORT_SELECT
static const esp_vfs_fs_ops_t s_cdcacm_vfs = { static const esp_vfs_fs_ops_t s_cdcacm_vfs = {
.write = &cdcacm_write, .write_p = &cdcacm_write,
.open = &cdcacm_open, .open_p = &cdcacm_open,
.fstat = &cdcacm_fstat, .fstat_p = &cdcacm_fstat,
.close = &cdcacm_close, .close_p = &cdcacm_close,
.read = &cdcacm_read, .read_p = &cdcacm_read,
.fcntl = &cdcacm_fcntl, .fcntl_p = &cdcacm_fcntl,
.fsync = &cdcacm_fsync, .fsync_p = &cdcacm_fsync,
#ifdef CONFIG_VFS_SUPPORT_SELECT #ifdef CONFIG_VFS_SUPPORT_SELECT
.select = &s_cdcacm_vfs_select, .select = &s_cdcacm_vfs_select,
#endif // CONFIG_VFS_SUPPORT_SELECT #endif // CONFIG_VFS_SUPPORT_SELECT
@@ -521,7 +521,7 @@ const esp_vfs_fs_ops_t *esp_vfs_cdcacm_get_vfs(void)
esp_err_t esp_vfs_dev_cdcacm_register(void) esp_err_t esp_vfs_dev_cdcacm_register(void)
{ {
return esp_vfs_register_fs("/dev/cdcacm", &s_cdcacm_vfs, ESP_VFS_FLAG_STATIC, NULL); return esp_vfs_register_fs("/dev/cdcacm", &s_cdcacm_vfs, ESP_VFS_FLAG_STATIC | ESP_VFS_FLAG_CONTEXT_PTR, NULL);
} }
#if CONFIG_ESP_CONSOLE_USB_CDC #if CONFIG_ESP_CONSOLE_USB_CDC
ESP_SYSTEM_INIT_FN(init_vfs_usb_cdc_rom_console, CORE, BIT(0), 113) ESP_SYSTEM_INIT_FN(init_vfs_usb_cdc_rom_console, CORE, BIT(0), 113)
+25 -10
View File
@@ -65,17 +65,32 @@ int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct
#endif // CONFIG_VFS_SUPPORT_SELECT #endif // CONFIG_VFS_SUPPORT_SELECT
static int lwip_fcntl_r_wrapper(int fd, int cmd, int arg) static int lwip_write_r_wrapper(__attribute__((unused)) void *ctx, int fd, const void *data, size_t size)
{
return lwip_write(fd, data, size);
}
static int lwip_read_r_wrapper(__attribute__((unused)) void *ctx, int fd, void *data, size_t size)
{
return lwip_read(fd, data, size);
}
static int lwip_close_r_wrapper(__attribute__((unused)) void *ctx, int fd)
{
return lwip_close(fd);
}
static int lwip_fcntl_r_wrapper(__attribute__((unused)) void *ctx, int fd, int cmd, int arg)
{ {
return lwip_fcntl(fd, cmd, arg); return lwip_fcntl(fd, cmd, arg);
} }
static int lwip_ioctl_r_wrapper(int fd, int cmd, va_list args) static int lwip_ioctl_r_wrapper(__attribute__((unused)) void *ctx, int fd, int cmd, va_list args)
{ {
return lwip_ioctl(fd, cmd, va_arg(args, void *)); return lwip_ioctl(fd, cmd, va_arg(args, void *));
} }
static int lwip_fstat(int fd, struct stat * st) static int lwip_fstat(__attribute__((unused)) void *ctx, int fd, struct stat * st)
{ {
if (st == NULL || fd < LWIP_SOCKET_OFFSET || fd > (MAX_FDS - 1)) { if (st == NULL || fd < LWIP_SOCKET_OFFSET || fd > (MAX_FDS - 1)) {
errno = EBADF; errno = EBADF;
@@ -102,12 +117,12 @@ void esp_vfs_lwip_sockets_register(void)
#endif #endif
static const esp_vfs_fs_ops_t s_lwip_vfs = { static const esp_vfs_fs_ops_t s_lwip_vfs = {
.write = &lwip_write, .write_p = &lwip_write_r_wrapper,
.read = &lwip_read, .read_p = &lwip_read_r_wrapper,
.close = &lwip_close, .close_p = &lwip_close_r_wrapper,
.fstat = &lwip_fstat, .fstat_p = &lwip_fstat,
.fcntl = &lwip_fcntl_r_wrapper, .fcntl_p = &lwip_fcntl_r_wrapper,
.ioctl = &lwip_ioctl_r_wrapper, .ioctl_p = &lwip_ioctl_r_wrapper,
#ifdef CONFIG_VFS_SUPPORT_SELECT #ifdef CONFIG_VFS_SUPPORT_SELECT
.select = &s_lwip_select_ops, .select = &s_lwip_select_ops,
#endif #endif
@@ -120,7 +135,7 @@ void esp_vfs_lwip_sockets_register(void)
* No context pointer needed -> flags have no ESP_VFS_FLAG_CONTEXT_PTR. * No context pointer needed -> flags have no ESP_VFS_FLAG_CONTEXT_PTR.
*/ */
ESP_ERROR_CHECK(esp_vfs_register_fd_range(&s_lwip_vfs, ESP_ERROR_CHECK(esp_vfs_register_fd_range(&s_lwip_vfs,
ESP_VFS_FLAG_STATIC, ESP_VFS_FLAG_STATIC | ESP_VFS_FLAG_CONTEXT_PTR,
NULL /* ctx */, NULL /* ctx */,
LWIP_SOCKET_OFFSET, LWIP_SOCKET_OFFSET,
MAX_FDS)); MAX_FDS));
+38 -38
View File
@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@@ -54,39 +54,39 @@ static const char* TAG = "nullfs";
static vfs_null_ctx_t g_fds = 0; static vfs_null_ctx_t g_fds = 0;
static ssize_t vfs_null_write(int fd, const void *data, size_t size); static ssize_t vfs_null_write(void *ctx, int fd, const void *data, size_t size);
static off_t vfs_null_lseek(int fd, off_t offset, int whence); static off_t vfs_null_lseek(void *ctx, int fd, off_t offset, int whence);
static ssize_t vfs_null_read(int fd, void *data, size_t size); static ssize_t vfs_null_read(void *ctx, int fd, void *data, size_t size);
static ssize_t vfs_null_pread(int fd, void *data, size_t size, off_t offset); static ssize_t vfs_null_pread(void *ctx, int fd, void *data, size_t size, off_t offset);
static ssize_t vfs_null_pwrite(int fd, const void *data, size_t size, off_t offset); static ssize_t vfs_null_pwrite(void *ctx, int fd, const void *data, size_t size, off_t offset);
static int vfs_null_open(const char* path, int flags, int mode); static int vfs_null_open(void *ctx, const char* path, int flags, int mode);
static int vfs_null_close(int fd); static int vfs_null_close(void *ctx, int fd);
static int vfs_null_fstat(int fd, struct stat *st); static int vfs_null_fstat(void *ctx, int fd, struct stat *st);
#if CONFIG_VFS_SUPPORT_DIR #if CONFIG_VFS_SUPPORT_DIR
static int vfs_null_stat(const char* path, struct stat *st); static int vfs_null_stat(void *ctx, const char* path, struct stat *st);
#endif // CONFIG_VFS_SUPPORT_DIR #endif // CONFIG_VFS_SUPPORT_DIR
static int vfs_null_fcntl(int fd, int cmd, int arg); static int vfs_null_fcntl(void *ctx, int fd, int cmd, int arg);
static int vfs_null_ioctl(int fd, int cmd, va_list args); static int vfs_null_ioctl(void *ctx, int fd, int cmd, va_list args);
static int vfs_null_fsync(int fd); static int vfs_null_fsync(void *ctx, int fd);
#if CONFIG_VFS_SUPPORT_DIR #if CONFIG_VFS_SUPPORT_DIR
static const esp_vfs_dir_ops_t s_vfs_null_dir = { static const esp_vfs_dir_ops_t s_vfs_null_dir = {
.stat = &vfs_null_stat, .stat_p = &vfs_null_stat,
}; };
#endif // CONFIG_VFS_SUPPORT_DIR #endif // CONFIG_VFS_SUPPORT_DIR
static const esp_vfs_fs_ops_t s_vfs_null = { static const esp_vfs_fs_ops_t s_vfs_null = {
.write = &vfs_null_write, .write_p = &vfs_null_write,
.lseek = &vfs_null_lseek, .lseek_p = &vfs_null_lseek,
.read = &vfs_null_read, .read_p = &vfs_null_read,
.pread = &vfs_null_pread, .pread_p = &vfs_null_pread,
.pwrite = &vfs_null_pwrite, .pwrite_p = &vfs_null_pwrite,
.open = &vfs_null_open, .open_p = &vfs_null_open,
.close = &vfs_null_close, .close_p = &vfs_null_close,
.fstat = &vfs_null_fstat, .fstat_p = &vfs_null_fstat,
.fcntl = &vfs_null_fcntl, .fcntl_p = &vfs_null_fcntl,
.ioctl = &vfs_null_ioctl, .ioctl_p = &vfs_null_ioctl,
.fsync = &vfs_null_fsync, .fsync_p = &vfs_null_fsync,
#if CONFIG_VFS_SUPPORT_DIR #if CONFIG_VFS_SUPPORT_DIR
.dir = &s_vfs_null_dir, .dir = &s_vfs_null_dir,
#endif // CONFIG_VFS_SUPPORT_DIR #endif // CONFIG_VFS_SUPPORT_DIR
@@ -99,10 +99,10 @@ const esp_vfs_fs_ops_t *esp_vfs_null_get_vfs(void)
esp_err_t esp_vfs_null_register(void) esp_err_t esp_vfs_null_register(void)
{ {
return esp_vfs_register_fs("/dev/null", &s_vfs_null, ESP_VFS_FLAG_STATIC, NULL); return esp_vfs_register_fs("/dev/null", &s_vfs_null, ESP_VFS_FLAG_STATIC | ESP_VFS_FLAG_CONTEXT_PTR, NULL);
} }
static ssize_t vfs_null_write(int fd, const void *data, size_t size) static ssize_t vfs_null_write(__attribute__((unused)) void *ctx, int fd, const void *data, size_t size)
{ {
UNUSED(data); UNUSED(data);
@@ -114,7 +114,7 @@ static ssize_t vfs_null_write(int fd, const void *data, size_t size)
return -1; return -1;
} }
static off_t vfs_null_lseek(int fd, off_t offset, int whence) static off_t vfs_null_lseek(__attribute__((unused)) void *ctx, int fd, off_t offset, int whence)
{ {
UNUSED(offset); UNUSED(offset);
@@ -134,7 +134,7 @@ static off_t vfs_null_lseek(int fd, off_t offset, int whence)
} }
} }
static ssize_t vfs_null_read(int fd, void *data, size_t size) static ssize_t vfs_null_read(__attribute__((unused)) void *ctx, int fd, void *data, size_t size)
{ {
UNUSED(data); UNUSED(data);
@@ -148,7 +148,7 @@ static ssize_t vfs_null_read(int fd, void *data, size_t size)
return -1; return -1;
} }
static int vfs_null_pread(int fd, void *data, size_t size, off_t offset) static int vfs_null_pread(__attribute__((unused)) void *ctx, int fd, void *data, size_t size, off_t offset)
{ {
UNUSED(data); UNUSED(data);
UNUSED(size); UNUSED(size);
@@ -165,7 +165,7 @@ static int vfs_null_pread(int fd, void *data, size_t size, off_t offset)
} }
static int vfs_null_pwrite(int fd, const void *data, size_t size, off_t offset) static int vfs_null_pwrite(__attribute__((unused)) void *ctx, int fd, const void *data, size_t size, off_t offset)
{ {
UNUSED(data); UNUSED(data);
UNUSED(offset); UNUSED(offset);
@@ -191,7 +191,7 @@ static int vfs_null_get_empty_fd(void)
return -1; return -1;
} }
static int vfs_null_open(const char* path, int flags, int mode) static int vfs_null_open(__attribute__((unused)) void *ctx, const char* path, int flags, int mode)
{ {
UNUSED(mode); UNUSED(mode);
@@ -226,7 +226,7 @@ static int vfs_null_open(const char* path, int flags, int mode)
return fd; return fd;
} }
static int vfs_null_close(int fd) static int vfs_null_close(__attribute__((unused)) void *ctx, int fd)
{ {
if (!FD_IN_RANGE(fd)) { if (!FD_IN_RANGE(fd)) {
errno = EBADF; errno = EBADF;
@@ -237,7 +237,7 @@ static int vfs_null_close(int fd)
return 0; return 0;
} }
static int vfs_null_fstat(int fd, struct stat *st) static int vfs_null_fstat(__attribute__((unused)) void *ctx, int fd, struct stat *st)
{ {
if (!FD_IN_RANGE(fd)) { if (!FD_IN_RANGE(fd)) {
errno = EBADF; errno = EBADF;
@@ -256,7 +256,7 @@ static int vfs_null_fstat(int fd, struct stat *st)
#if CONFIG_VFS_SUPPORT_DIR #if CONFIG_VFS_SUPPORT_DIR
static int vfs_null_stat(const char* path, struct stat *st) static int vfs_null_stat(__attribute__((unused)) void *ctx, const char* path, struct stat *st)
{ {
if (strcmp(path, "/") != 0) { if (strcmp(path, "/") != 0) {
errno = ENOENT; errno = ENOENT;
@@ -275,7 +275,7 @@ static int vfs_null_stat(const char* path, struct stat *st)
#endif // CONFIG_VFS_SUPPORT_DIR #endif // CONFIG_VFS_SUPPORT_DIR
static int vfs_null_fcntl(int fd, int cmd, int arg) static int vfs_null_fcntl(__attribute__((unused)) void *ctx, int fd, int cmd, int arg)
{ {
UNUSED(arg); UNUSED(arg);
@@ -291,7 +291,7 @@ static int vfs_null_fcntl(int fd, int cmd, int arg)
} }
} }
static int vfs_null_ioctl(int fd, int cmd, va_list args) static int vfs_null_ioctl(__attribute__((unused)) void *ctx, int fd, int cmd, va_list args)
{ {
UNUSED(args); UNUSED(args);
@@ -307,7 +307,7 @@ static int vfs_null_ioctl(int fd, int cmd, va_list args)
} }
} }
static int vfs_null_fsync(int fd) static int vfs_null_fsync(__attribute__((unused)) void *ctx, int fd)
{ {
if (!FD_IN_RANGE(fd)) { if (!FD_IN_RANGE(fd)) {
errno = EBADF; errno = EBADF;
@@ -9,3 +9,6 @@ CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
CONFIG_ESP_TASK_WDT_INIT=n CONFIG_ESP_TASK_WDT_INIT=n
CONFIG_VFS_MAX_COUNT=10 CONFIG_VFS_MAX_COUNT=10
# We should still run tests for all variants...
CONFIG_VFS_SUPPRESS_CTX_DEPRECATION=y
+7 -7
View File
@@ -243,7 +243,7 @@ static ssize_t signal_event_fd_from_isr(int fd, const void *data, size_t size)
return ret; return ret;
} }
static ssize_t event_write(int fd, const void *data, size_t size) static ssize_t event_write(__attribute__((unused)) void *ctx, int fd, const void *data, size_t size)
{ {
ssize_t ret = -1; ssize_t ret = -1;
@@ -284,7 +284,7 @@ static ssize_t event_write(int fd, const void *data, size_t size)
return ret; return ret;
} }
static ssize_t event_read(int fd, void *data, size_t size) static ssize_t event_read(__attribute__((unused)) void *ctx, int fd, void *data, size_t size)
{ {
ssize_t ret = -1; ssize_t ret = -1;
@@ -318,7 +318,7 @@ static ssize_t event_read(int fd, void *data, size_t size)
return ret; return ret;
} }
static int event_close(int fd) static int event_close(__attribute__((unused)) void *ctx, int fd)
{ {
int ret = -1; int ret = -1;
@@ -359,9 +359,9 @@ static const esp_vfs_select_ops_t s_vfs_eventfd_select = {
#endif #endif
static const esp_vfs_fs_ops_t s_vfs_eventfd = { static const esp_vfs_fs_ops_t s_vfs_eventfd = {
.write = &event_write, .write_p = &event_write,
.read = &event_read, .read_p = &event_read,
.close = &event_close, .close_p = &event_close,
#ifdef CONFIG_VFS_SUPPORT_SELECT #ifdef CONFIG_VFS_SUPPORT_SELECT
.select = &s_vfs_eventfd_select, .select = &s_vfs_eventfd_select,
#endif #endif
@@ -383,7 +383,7 @@ esp_err_t esp_vfs_eventfd_register(const esp_vfs_eventfd_config_t *config)
s_events[i].fd = FD_INVALID; s_events[i].fd = FD_INVALID;
} }
return esp_vfs_register_fs_with_id(&s_vfs_eventfd, ESP_VFS_FLAG_STATIC | ESP_VFS_FLAG_STATIC, NULL, &s_eventfd_vfs_id); return esp_vfs_register_fs_with_id(&s_vfs_eventfd, ESP_VFS_FLAG_STATIC | ESP_VFS_FLAG_CONTEXT_PTR, NULL, &s_eventfd_vfs_id);
} }
esp_err_t esp_vfs_eventfd_unregister(void) esp_err_t esp_vfs_eventfd_unregister(void)