From 9bd81f4d5c940fea200d22da28a43654e151a6b0 Mon Sep 17 00:00:00 2001 From: Guillaume Souchere Date: Thu, 11 Apr 2024 12:38:35 +0200 Subject: [PATCH] fix(console): Fsync not propagated to secondary output Calls to fsync need to also be propagated to secondary output when CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG is enabled. Closes https://github.com/espressif/esp-idf/issues/13162 --- components/vfs/vfs_console.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/components/vfs/vfs_console.c b/components/vfs/vfs_console.c index 1360be33cc68..f9604917b036 100644 --- a/components/vfs/vfs_console.c +++ b/components/vfs/vfs_console.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -104,7 +104,11 @@ int console_fcntl(int fd, int cmd, int arg) int console_fsync(int fd) { - return get_vfs_for_index(primary_vfs_index)->vfs.fsync(vfs_console.fd_primary); + const int ret_val = get_vfs_for_index(primary_vfs_index)->vfs.fsync(vfs_console.fd_primary); +#if CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG + (void)get_vfs_for_index(secondary_vfs_index)->vfs.fsync(vfs_console.fd_secondary); +#endif + return ret_val; } #ifdef CONFIG_VFS_SUPPORT_DIR