esp_vfs_unregister_with_id() scanned only the first VFS_MAX_COUNT
(default 8, max 20) slots of s_fd_table[MAX_FDS] (MAX_FDS = FD_SETSIZE,
64 on non-Cygwin targets) when clearing stale references to the
unregistered VFS. Every other loop over s_fd_table in this file
(and in vfs_calls.c) correctly bounds on MAX_FDS.
Any global fd >= VFS_MAX_COUNT that was still open against the VFS
being unregistered was left with a stale vfs_index pointing at a slot
that esp_get_free_index() can immediately hand out to the next
esp_vfs_register*() call, causing later operations on that fd to be
routed into an unrelated filesystem's context.
Signed-off-by: yi chen <94xhn1@gmail.com>
Reformat the test partition before each mount so those tests always start from
a known-empty filesystem.
Co-authored-by: Cursor <cursoragent@cursor.com>
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
In CMake v2's recursive component evaluation model, when a component
triggers the inclusion of another component via idf_component_include(),
the child component's directory scope inherits variables from the
caller's scope chain through the idf_component_include() function scope
and add_subdirectory().
The vfs component's Linux target block used list(APPEND ...) without
first initializing the srcs, inc, and priv_inc variables. This was
harmless when vfs was evaluated before esp_stdio, but after commit
5fac0b7386 ("feat(console): Move IO initialization outside of the
console component"), esp_stdio became a real component for the Linux
target and started calling idf_component_include(vfs). When esp_stdio
is evaluated first, its srcs variable (containing stdio_port.c and
linux/esp_stdio_linux.c) leaks into vfs's scope, causing the build
to fail with "Cannot find source file: components/vfs/stdio_port.c".
Fix by explicitly initializing all local variables at the top of the
Linux target block before appending to them.
Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
Zero dummy VFS output fd sets in start_select.
This keeps revents limited to readiness from end_select.
It prevents spurious POLLERR bits in poll() regression tests.
Split the idf_performance.h and target ver, which hold the performance
thresholds, into the headers of each testing.
In the past pytest also parse the common header to get the thresholds.
Now the logic is also removed. Performance thresholds are supposed to be
in the pytest scripts.
esp_stdio contains everything the old esp_vfs_console contained (the vfs stdio glue layer)
as well as other functionality related to stdio (previously referred to as console)