mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
refactor(stdio): remove fd table, forward opens to primary backend
Remove the internal fd table (fd_entry_t, is_fd_valid, fd_allows_read/write,
ESP_STDIO_BASIC_MODE tracking) from the console VFS.
Instead, console_open forwards directly to the primary backend's open_p,
so each open("/dev/console") creates a real fd in the underlying driver.
Read/write/fstat/fcntl/fsync all operate on the per-open fd from the
primary, not a stored init-time fd.
Structure:
- s_primary: separate variable for the primary backend entry
- s_auxiliary[]: slot-based array for auxiliary sinks (NULL = free)
- Scans all slots (no count variable) with NULL guards
- Auxiliaries opened lazily on first console open
- Closed when last console fd is closed (refcounted via s_open_count)
- Write and fsync fan-out protected by s_lock
This commit is contained in:
@@ -185,28 +185,6 @@ menu "ESP-STDIO"
|
||||
If enabled, esp_rom_printf and ESP_EARLY_LOG output will also be sent over USB CDC.
|
||||
Disabling this option saves about 1kB or RAM.
|
||||
|
||||
config ESP_STDIO_BASIC_MODE
|
||||
bool "Use basic /dev/console descriptor handling"
|
||||
depends on VFS_SUPPORT_IO
|
||||
default n
|
||||
help
|
||||
Enable the low-overhead legacy /dev/console descriptor handling.
|
||||
|
||||
In basic mode, all open() calls share a single internal descriptor. This keeps RAM usage
|
||||
lower, but disables checks for per-fd behaviour, such as read-only versus write-only access.
|
||||
|
||||
config ESP_STDIO_MAX_FDS
|
||||
int "Max logical stdio file descriptors"
|
||||
depends on VFS_SUPPORT_IO && !ESP_STDIO_BASIC_MODE
|
||||
range 3 64
|
||||
default 16
|
||||
help
|
||||
Maximum number of logical /dev/console descriptors tracked by esp_stdio VFS.
|
||||
|
||||
stdin, stdout, and stderr each occupy one slot. The default leaves room for additional
|
||||
opens of /dev/console (e.g. dup2, reopen). If set to exactly 3, only the three standard
|
||||
streams fit and further opens fail with ENFILE unless one is closed first.
|
||||
|
||||
config ESP_STDIO_MAX_VFS_ENTRIES
|
||||
int "Maximum number of registerable VFS sinks"
|
||||
depends on VFS_SUPPORT_IO
|
||||
|
||||
Reference in New Issue
Block a user