Swatantra-66 commented on issue #20414:
URL: https://github.com/apache/nuttx/issues/20414#issuecomment-6152743354
@acassis @jingfei195887 @arnavsharma990
Regarding the forensic breakdown across subsystems—particularly `libfs.a`
(+3,517 B) and `libsched.a` (+4,314 B)—and building on the `DEFAULT_SMALL`
precedent in draft PR #20628:
The directory layer in `fs_dir.c` accounts for ~2.1 KB of the growth.
Routing directories through the file layer (`open(O_DIRECTORY)` -> `file_readv`
-> `dir_read`) was introduced for POSIX descriptor conformance (`dirfd`,
`fdopendir`, `fchdir`, `/proc/self/fd`). However, on memory-constrained targets
like `stm32f103-minimum:nsh` and 16-bit AVR architectures, pulling in the
entire descriptor apparatus just to support directory traversal imposes an
unnecessary footprint penalty.
Introducing **`CONFIG_FS_DIRENT_LITE`** (configured as `default
!DEFAULT_SMALL`) provides the appropriate opt-out mechanism:
1. **Type Definition (`<dirent.h>`)**:
Under `CONFIG_FS_DIRENT_LITE`, `DIR` wraps an internal handle/pointer to
`struct fs_dirent_s` directly, rather than storing an integer file descriptor
`fd`.
2. **File Layer Decoupling**:
`opendir()`, `readdir()`, and `closedir()` resolve the target inode
directly and invoke the filesystem operations (`inode->u.i_mops->readdir`) or
pseudo-root traversals. This completely bypasses:
- The file descriptor table (`fs_files.c`)
- The synthetic directory inode (`g_dir_inode`) and operations table
(`g_dir_fileops`)
- The `struct uio` vectored I/O path (`file_readv`)
- Path reconstruction (`fd_path` / `inode_getpath`)
3. **Conformance Boundary**:
APIs that strictly depend on directory descriptors (`dirfd()`,
`fdopendir()`, `fchdir()` on directory fds) are conditionally compiled out
under this option.
I can assist with the following:
- Prototyping the conditional decoupling between `libs/libc/dirent/` and
`fs/vfs/fs_dir.c`.
- Measuring the exact linked image delta (`.text`, `.data`, `.bss`) on
`stm32f103-minimum:nsh`.
- Running regression verification on `sim:nsh` across basic directory
commands (`ls`, `cd`, nested path traversals).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]