mirror of
https://github.com/espressif/esp-idf.git
synced 2026-09-22 13:01:16 +03:00
Rework the syscall interposition architecture so FreeRTOS works standalone (without VFS) and VFS optionally overrides with strong symbols. All kernel FDs are registered with VFS via esp_vfs_register_fd_with_local_fd, so the application only sees VFS-allocated FD numbers, preventing numerical collisions between kernel FDs and VFS-internal FD slots. FreeRTOS side: - Create linux_port_coop_internal.h with LINUX_COOP_IO_LOOP, LINUX_COOP_RESOLVE, linux_coop_yield and FD state table functions - Export cooperative I/O primitives (freertos_linux_coop_read/write/ open/close/fcntl/select/pread/pwrite/readv/writev/recv/send/ recvfrom/sendto/recvmsg/sendmsg/connect/accept/pselect/poll/ socket/socketpair/pipe/pipe2/dup/dup2/syscalls_init) - Define weak POSIX symbols calling through to the cooperative primitives; keep nanosleep/sleep/usleep as strong (not FD-related) - Refactor freertos_linux_coop_syscalls.h into a pure public API header VFS side: - Register the Linux host FS with esp_vfs_register_fs_with_id() as a proper VFS driver; register stdin/stdout/stderr at init (priority 99) - Rewrite vfs_linux.c with strong POSIX symbols dispatching through esp_vfs_* - Add strong overrides for FD-creating syscalls (open, pipe, pipe2, socket, socketpair, dup, dup2, accept) that register returned FDs with VFS - Add strong overrides for FD-translating syscalls (readv, writev, recv, send, recvfrom, sendto, recvmsg, sendmsg, connect, pselect, poll) that translate VFS FD to kernel FD - Delete vfs_coop_syscalls.c (absorbed into FreeRTOS weak + VFS strong) - Update CMakeLists.txt: remove vfs_coop_syscalls.c, add linker hook