diff --git a/components/esp_driver_uart/src/uart_vfs.c b/components/esp_driver_uart/src/uart_vfs.c index 921f11fb09..f733ee88c2 100644 --- a/components/esp_driver_uart/src/uart_vfs.c +++ b/components/esp_driver_uart/src/uart_vfs.c @@ -147,7 +147,7 @@ static esp_err_t uart_end_select(void *end_select_args); #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, // and error out if write is requested @@ -223,7 +223,7 @@ static int uart_rx_char_via_driver(int fd) 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); 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; } -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); char *data_c = (char *) data; @@ -343,7 +343,7 @@ static ssize_t uart_read(int fd, void* data, size_t size) 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); memset(st, 0, sizeof(*st)); @@ -351,13 +351,13 @@ static int uart_fstat(int fd, struct stat * st) return 0; } -static int uart_close(int fd) +static int uart_close(__attribute__((unused)) void *ctx, int fd) { assert(fd >= 0 && fd < 3); 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); int result = 0; @@ -378,7 +378,7 @@ static int uart_fcntl(int fd, int cmd, int arg) #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; @@ -401,7 +401,7 @@ static int uart_access(const char *path, int amode) #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); _lock_acquire_recursive(&s_ctx[fd]->write_lock); @@ -602,7 +602,7 @@ static esp_err_t uart_end_select(void *end_select_args) #endif // CONFIG_VFS_SUPPORT_SELECT #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) { errno = EBADF; @@ -807,7 +807,7 @@ static int uart_tcsetattr(int fd, int optional_actions, const struct termios *p) 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) { errno = EBADF; @@ -1016,7 +1016,7 @@ static int uart_tcgetattr(int fd, struct termios *p) return 0; } -static int uart_tcdrain(int fd) +static int uart_tcdrain(__attribute__((unused)) void *ctx, int fd) { if (fd < 0 || fd >= UART_NUM) { errno = EBADF; @@ -1031,7 +1031,7 @@ static int uart_tcdrain(int fd) 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) { errno = EBADF; @@ -1055,7 +1055,7 @@ static int uart_tcflush(int fd, int select) #ifdef CONFIG_VFS_SUPPORT_DIR static const esp_vfs_dir_ops_t s_vfs_uart_dir = { - .access = &uart_access, + .access_p = &uart_access, }; #endif // CONFIG_VFS_SUPPORT_DIR @@ -1068,21 +1068,21 @@ static const esp_vfs_select_ops_t s_vfs_uart_select = { #ifdef CONFIG_VFS_SUPPORT_TERMIOS static const esp_vfs_termios_ops_t s_vfs_uart_termios = { - .tcsetattr = &uart_tcsetattr, - .tcgetattr = &uart_tcgetattr, - .tcdrain = &uart_tcdrain, - .tcflush = &uart_tcflush, + .tcsetattr_p = &uart_tcsetattr, + .tcgetattr_p = &uart_tcgetattr, + .tcdrain_p = &uart_tcdrain, + .tcflush_p = &uart_tcflush, }; #endif // CONFIG_VFS_SUPPORT_TERMIOS static const esp_vfs_fs_ops_t s_vfs_uart = { - .write = &uart_write, - .open = &uart_open, - .fstat = &uart_fstat, - .close = &uart_close, - .read = &uart_read, - .fcntl = &uart_fcntl, - .fsync = &uart_fsync, + .write_p = &uart_write, + .open_p = &uart_open, + .fstat_p = &uart_fstat, + .close_p = &uart_close, + .read_p = &uart_read, + .fcntl_p = &uart_fcntl, + .fsync_p = &uart_fsync, #ifdef CONFIG_VFS_SUPPORT_DIR .dir = &s_vfs_uart_dir, #endif // CONFIG_VFS_SUPPORT_DIR @@ -1101,7 +1101,7 @@ const esp_vfs_fs_ops_t *esp_vfs_uart_get_vfs(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) diff --git a/components/esp_driver_usb_serial_jtag/src/usb_serial_jtag_vfs.c b/components/esp_driver_usb_serial_jtag/src/usb_serial_jtag_vfs.c index 6a923d8620..3418b7a983 100644 --- a/components/esp_driver_usb_serial_jtag/src/usb_serial_jtag_vfs.c +++ b/components/esp_driver_usb_serial_jtag/src/usb_serial_jtag_vfs.c @@ -138,7 +138,7 @@ static esp_err_t usb_serial_jtag_end_select(void *end_select_args); #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); return USJ_LOCAL_FD; @@ -179,7 +179,7 @@ static int usb_serial_jtag_rx_char_no_driver(int fd) 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()) { // TODO: IDF-14303 @@ -227,7 +227,7 @@ static void usb_serial_jtag_return_char(int fd, int 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()) { // TODO: IDF-14303 @@ -305,19 +305,19 @@ static ssize_t usb_serial_jtag_read(int fd, void* data, size_t size) 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)); st->st_mode = S_IFCHR; return 0; } -static int usb_serial_jtag_close(int fd) +static int usb_serial_jtag_close(__attribute__((unused)) void *ctx, int fd) { 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; if (cmd == F_GETFL) { @@ -354,7 +354,7 @@ static int usb_serial_jtag_wait_tx_done_no_driver(int fd) 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()) { // 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 #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) { errno = EINVAL; @@ -561,7 +561,7 @@ static int usb_serial_jtag_tcsetattr(int fd, int optional_actions, const struct // nothing to do break; case TCSADRAIN: - usb_serial_jtag_fsync(fd); + usb_serial_jtag_fsync(ctx, fd); break; case TCSAFLUSH: // Not applicable. @@ -581,7 +581,7 @@ static int usb_serial_jtag_tcsetattr(int fd, int optional_actions, const struct 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) { errno = EINVAL; @@ -606,13 +606,13 @@ static int usb_serial_jtag_tcgetattr(int fd, struct termios *p) 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; } -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. errno = EINVAL; @@ -638,21 +638,21 @@ static const esp_vfs_select_ops_t s_vfs_jtag_select = { #endif // CONFIG_VFS_SUPPORT_SELECT #ifdef CONFIG_VFS_SUPPORT_TERMIOS static const esp_vfs_termios_ops_t s_vfs_jtag_termios = { - .tcsetattr = &usb_serial_jtag_tcsetattr, - .tcgetattr = &usb_serial_jtag_tcgetattr, - .tcdrain = &usb_serial_jtag_tcdrain, - .tcflush = &usb_serial_jtag_tcflush, + .tcsetattr_p = &usb_serial_jtag_tcsetattr, + .tcgetattr_p = &usb_serial_jtag_tcgetattr, + .tcdrain_p = &usb_serial_jtag_tcdrain, + .tcflush_p = &usb_serial_jtag_tcflush, }; #endif // CONFIG_VFS_SUPPORT_TERMIOS static const esp_vfs_fs_ops_t s_vfs_jtag = { - .write = &usb_serial_jtag_write, - .open = &usb_serial_jtag_open, - .fstat = &usb_serial_jtag_fstat, - .close = &usb_serial_jtag_close, - .read = &usb_serial_jtag_read, - .fcntl = &usb_serial_jtag_fcntl, - .fsync = &usb_serial_jtag_fsync, + .write_p = &usb_serial_jtag_write, + .open_p = &usb_serial_jtag_open, + .fstat_p = &usb_serial_jtag_fstat, + .close_p = &usb_serial_jtag_close, + .read_p = &usb_serial_jtag_read, + .fcntl_p = &usb_serial_jtag_fcntl, + .fsync_p = &usb_serial_jtag_fsync, #ifdef CONFIG_VFS_SUPPORT_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) { // "/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 @@ -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) { // "/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; } #endif diff --git a/components/esp_netif/vfs_l2tap/esp_vfs_l2tap.c b/components/esp_netif/vfs_l2tap/esp_vfs_l2tap.c index 399d99dc69..036b64140b 100644 --- a/components/esp_netif/vfs_l2tap/esp_vfs_l2tap.c +++ b/components/esp_netif/vfs_l2tap/esp_vfs_l2tap.c @@ -259,7 +259,7 @@ esp_err_t esp_vfs_l2tap_eth_filter_frame(l2tap_iodriver_handle driver_handle, vo } /* ====================== 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; @@ -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; 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) 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; } -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; @@ -465,7 +465,7 @@ void l2tap_clean_task(void *task_param) 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) { // 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; } -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; switch (cmd) { @@ -608,7 +608,7 @@ static void l2tap_set_nonblocking(l2tap_context_t *l2tap_socket, bool nonblock) 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; if (cmd == F_GETFL) { @@ -801,12 +801,12 @@ static const esp_vfs_select_ops_t s_vfs_l2tap_select = { #endif //CONFIG_VFS_SUPPORT_SELECT static const esp_vfs_fs_ops_t s_vfs_l2tap = { - .write = &l2tap_write, - .open = &l2tap_open, - .close = &l2tap_close, - .read = &l2tap_read, - .fcntl = &l2tap_fcntl, - .ioctl = &l2tap_ioctl, + .write_p = &l2tap_write, + .open_p = &l2tap_open, + .close_p = &l2tap_close, + .read_p = &l2tap_read, + .fcntl_p = &l2tap_fcntl, + .ioctl_p = &l2tap_ioctl, #ifdef CONFIG_VFS_SUPPORT_SELECT .select = &s_vfs_l2tap_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"); 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; } diff --git a/components/esp_stdio/stdio_vfs.c b/components/esp_stdio/stdio_vfs.c index e8d3e38fd8..806c4f1d7b 100644 --- a/components/esp_stdio/stdio_vfs.c +++ b/components/esp_stdio/stdio_vfs.c @@ -60,7 +60,7 @@ static vfs_console_context_t vfs_console = {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) { // Underlying fd is already open, so just increment the open count @@ -90,7 +90,7 @@ int console_open(const char * path, int flags, int mode) 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); #if CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG @@ -99,12 +99,12 @@ ssize_t console_write(int fd, const void *data, size_t 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); } -int console_close(int fd) +int console_close(__attribute__((unused)) void *ctx, int fd) { if (s_open_count == 0) { errno = EBADF; @@ -126,17 +126,17 @@ int console_close(int fd) 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); } -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); } -int console_fsync(int fd) +int console_fsync(__attribute__((unused)) void *ctx, int fd) { const int ret_val = fsync(vfs_console.fd_primary); #if CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG @@ -146,7 +146,7 @@ int console_fsync(int fd) } #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. return access("/dev/uart/"STRINGIFY(CONFIG_ESP_CONSOLE_UART_NUM), amode); @@ -179,22 +179,22 @@ esp_err_t console_end_select(void *end_select_args) #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); } -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); } -int console_tcdrain(int fd) +int console_tcdrain(__attribute__((unused)) void *ctx, int fd) { 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); } @@ -202,7 +202,7 @@ int console_tcflush(int fd, int select) #ifdef CONFIG_VFS_SUPPORT_DIR static const esp_vfs_dir_ops_t s_vfs_console_dir = { - .access = &console_access, + .access_p = &console_access, }; #endif // CONFIG_VFS_SUPPORT_DIR @@ -215,21 +215,21 @@ static const esp_vfs_select_ops_t s_vfs_console_select = { #ifdef CONFIG_VFS_SUPPORT_TERMIOS static const esp_vfs_termios_ops_t s_vfs_console_termios = { - .tcsetattr = &console_tcsetattr, - .tcgetattr = &console_tcgetattr, - .tcdrain = &console_tcdrain, - .tcflush = &console_tcflush, + .tcsetattr_p = &console_tcsetattr, + .tcgetattr_p = &console_tcgetattr, + .tcdrain_p = &console_tcdrain, + .tcflush_p = &console_tcflush, }; #endif // CONFIG_VFS_SUPPORT_TERMIOS static const esp_vfs_fs_ops_t s_vfs_console = { - .write = &console_write, - .open = &console_open, - .fstat = &console_fstat, - .close = &console_close, - .read = &console_read, - .fcntl = &console_fcntl, - .fsync = &console_fsync, + .write_p = &console_write, + .open_p = &console_open, + .fstat_p = &console_fstat, + .close_p = &console_close, + .read_p = &console_read, + .fcntl_p = &console_fcntl, + .fsync_p = &console_fsync, #ifdef CONFIG_VFS_SUPPORT_DIR .dir = &s_vfs_console_dir, @@ -246,7 +246,7 @@ static const esp_vfs_fs_ops_t s_vfs_console = { 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) diff --git a/components/esp_usb_cdc_rom_console/vfs_cdcacm.c b/components/esp_usb_cdc_rom_console/vfs_cdcacm.c index 3026c86d25..c205b6f21f 100644 --- a/components/esp_usb_cdc_rom_console/vfs_cdcacm.c +++ b/components/esp_usb_cdc_rom_console/vfs_cdcacm.c @@ -78,7 +78,7 @@ static esp_err_t cdcacm_end_select(void *end_select_args); #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); 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; } -static int cdcacm_fsync(int fd) +static int cdcacm_fsync(__attribute__((unused)) void *ctx, int fd) { assert(fd == 0); _lock_acquire_recursive(&s_write_lock); @@ -110,12 +110,12 @@ static int cdcacm_fsync(int fd) 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 } -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); memset(st, 0, sizeof(*st)); @@ -123,7 +123,7 @@ static int cdcacm_fstat(int fd, struct stat *st) return 0; } -static int cdcacm_close(int fd) +static int cdcacm_close(__attribute__((unused)) void *ctx, int fd) { assert(fd == 0); return 0; @@ -174,7 +174,7 @@ static void cdcacm_return_char(int 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); char *data_c = (char *) data; @@ -289,7 +289,7 @@ static int cdcacm_disable_blocking(void) 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); int result; @@ -502,13 +502,13 @@ static const esp_vfs_select_ops_t s_cdcacm_vfs_select = { #endif // CONFIG_VFS_SUPPORT_SELECT static const esp_vfs_fs_ops_t s_cdcacm_vfs = { - .write = &cdcacm_write, - .open = &cdcacm_open, - .fstat = &cdcacm_fstat, - .close = &cdcacm_close, - .read = &cdcacm_read, - .fcntl = &cdcacm_fcntl, - .fsync = &cdcacm_fsync, + .write_p = &cdcacm_write, + .open_p = &cdcacm_open, + .fstat_p = &cdcacm_fstat, + .close_p = &cdcacm_close, + .read_p = &cdcacm_read, + .fcntl_p = &cdcacm_fcntl, + .fsync_p = &cdcacm_fsync, #ifdef CONFIG_VFS_SUPPORT_SELECT .select = &s_cdcacm_vfs_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) { - 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 ESP_SYSTEM_INIT_FN(init_vfs_usb_cdc_rom_console, CORE, BIT(0), 113) diff --git a/components/lwip/port/esp32xx/vfs_lwip.c b/components/lwip/port/esp32xx/vfs_lwip.c index c4c42d8220..dc466e4c4f 100644 --- a/components/lwip/port/esp32xx/vfs_lwip.c +++ b/components/lwip/port/esp32xx/vfs_lwip.c @@ -65,17 +65,32 @@ int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct #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); } -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 *)); } -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)) { errno = EBADF; @@ -102,12 +117,12 @@ void esp_vfs_lwip_sockets_register(void) #endif static const esp_vfs_fs_ops_t s_lwip_vfs = { - .write = &lwip_write, - .read = &lwip_read, - .close = &lwip_close, - .fstat = &lwip_fstat, - .fcntl = &lwip_fcntl_r_wrapper, - .ioctl = &lwip_ioctl_r_wrapper, + .write_p = &lwip_write_r_wrapper, + .read_p = &lwip_read_r_wrapper, + .close_p = &lwip_close_r_wrapper, + .fstat_p = &lwip_fstat, + .fcntl_p = &lwip_fcntl_r_wrapper, + .ioctl_p = &lwip_ioctl_r_wrapper, #ifdef CONFIG_VFS_SUPPORT_SELECT .select = &s_lwip_select_ops, #endif @@ -120,7 +135,7 @@ void esp_vfs_lwip_sockets_register(void) * No context pointer needed -> flags have no ESP_VFS_FLAG_CONTEXT_PTR. */ 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 */, LWIP_SOCKET_OFFSET, MAX_FDS)); diff --git a/components/vfs/nullfs.c b/components/vfs/nullfs.c index 9237f59b37..f67656e336 100644 --- a/components/vfs/nullfs.c +++ b/components/vfs/nullfs.c @@ -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 */ @@ -54,39 +54,39 @@ static const char* TAG = "nullfs"; static vfs_null_ctx_t g_fds = 0; -static ssize_t vfs_null_write(int fd, const void *data, size_t size); -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_pread(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 int vfs_null_open(const char* path, int flags, int mode); -static int vfs_null_close(int fd); -static int vfs_null_fstat(int fd, struct stat *st); +static ssize_t vfs_null_write(void *ctx, int fd, const void *data, size_t size); +static off_t vfs_null_lseek(void *ctx, int fd, off_t offset, int whence); +static ssize_t vfs_null_read(void *ctx, int fd, void *data, size_t size); +static ssize_t vfs_null_pread(void *ctx, int fd, 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(void *ctx, const char* path, int flags, int mode); +static int vfs_null_close(void *ctx, int fd); +static int vfs_null_fstat(void *ctx, int fd, struct stat *st); #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 -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_fsync(int fd); +static int vfs_null_fcntl(void *ctx, int fd, int cmd, int arg); +static int vfs_null_ioctl(void *ctx, int fd, int cmd, va_list args); +static int vfs_null_fsync(void *ctx, int fd); #if CONFIG_VFS_SUPPORT_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 static const esp_vfs_fs_ops_t s_vfs_null = { - .write = &vfs_null_write, - .lseek = &vfs_null_lseek, - .read = &vfs_null_read, - .pread = &vfs_null_pread, - .pwrite = &vfs_null_pwrite, - .open = &vfs_null_open, - .close = &vfs_null_close, - .fstat = &vfs_null_fstat, - .fcntl = &vfs_null_fcntl, - .ioctl = &vfs_null_ioctl, - .fsync = &vfs_null_fsync, + .write_p = &vfs_null_write, + .lseek_p = &vfs_null_lseek, + .read_p = &vfs_null_read, + .pread_p = &vfs_null_pread, + .pwrite_p = &vfs_null_pwrite, + .open_p = &vfs_null_open, + .close_p = &vfs_null_close, + .fstat_p = &vfs_null_fstat, + .fcntl_p = &vfs_null_fcntl, + .ioctl_p = &vfs_null_ioctl, + .fsync_p = &vfs_null_fsync, #if CONFIG_VFS_SUPPORT_DIR .dir = &s_vfs_null_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) { - 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); @@ -114,7 +114,7 @@ static ssize_t vfs_null_write(int fd, const void *data, size_t size) 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); @@ -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); @@ -148,7 +148,7 @@ static ssize_t vfs_null_read(int fd, void *data, size_t size) 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(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(offset); @@ -191,7 +191,7 @@ static int vfs_null_get_empty_fd(void) 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); @@ -226,7 +226,7 @@ static int vfs_null_open(const char* path, int flags, int mode) 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)) { errno = EBADF; @@ -237,7 +237,7 @@ static int vfs_null_close(int fd) 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)) { errno = EBADF; @@ -256,7 +256,7 @@ static int vfs_null_fstat(int fd, struct stat *st) #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) { errno = ENOENT; @@ -275,7 +275,7 @@ static int vfs_null_stat(const char* path, struct stat *st) #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); @@ -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); @@ -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)) { errno = EBADF; diff --git a/components/vfs/test_apps/sdkconfig.defaults b/components/vfs/test_apps/sdkconfig.defaults index a600d2e6c4..ca63c8ed45 100644 --- a/components/vfs/test_apps/sdkconfig.defaults +++ b/components/vfs/test_apps/sdkconfig.defaults @@ -9,3 +9,6 @@ CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" CONFIG_ESP_TASK_WDT_INIT=n CONFIG_VFS_MAX_COUNT=10 + +# We should still run tests for all variants... +CONFIG_VFS_SUPPRESS_CTX_DEPRECATION=y diff --git a/components/vfs/vfs_eventfd.c b/components/vfs/vfs_eventfd.c index bae6ecff9e..739425a69e 100644 --- a/components/vfs/vfs_eventfd.c +++ b/components/vfs/vfs_eventfd.c @@ -243,7 +243,7 @@ static ssize_t signal_event_fd_from_isr(int fd, const void *data, size_t size) 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; @@ -284,7 +284,7 @@ static ssize_t event_write(int fd, const void *data, size_t size) 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; @@ -318,7 +318,7 @@ static ssize_t event_read(int fd, void *data, size_t size) return ret; } -static int event_close(int fd) +static int event_close(__attribute__((unused)) void *ctx, int fd) { int ret = -1; @@ -359,9 +359,9 @@ static const esp_vfs_select_ops_t s_vfs_eventfd_select = { #endif static const esp_vfs_fs_ops_t s_vfs_eventfd = { - .write = &event_write, - .read = &event_read, - .close = &event_close, + .write_p = &event_write, + .read_p = &event_read, + .close_p = &event_close, #ifdef CONFIG_VFS_SUPPORT_SELECT .select = &s_vfs_eventfd_select, #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; } - 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)