Swatantra-66 commented on issue #20407: URL: https://github.com/apache/nuttx/issues/20407#issuecomment-6152597521
Hi @acassis, @jingfei195887, and @arnavsharma990, Seeing the exact subsystem partition—especially `libfs.a` (+3,517 B) and `libsched.a` (+4,314 B)—really clarifies where the growth comes from versus the conventional assumptions. The analysis on the directory layer by @jingfei195887 is spot-on: `fs_dir.c` routing directories through the file layer (`open(O_DIRECTORY)` -> `file_readv` -> `dir_read`) was a deliberate choice for POSIX descriptor conformance (`dirfd`, `fdopendir`, `fchdir`, `/proc/self/fd`), but for constrained targets like `stm32f103-minimum:nsh` (and 16-bit AVR targets), paying ~2.1 KB of flash just to iterate directories in NSH is a heavy toll. I strongly support introducing **`CONFIG_FS_DIRENT_LITE`** (and potentially a broader `CONFIG_VFS_LITE`). Under `CONFIG_FS_DIRENT_LITE`: 1. `DIR` in `<dirent.h>` can encapsulate a direct pointer/handle to `struct fs_dirent_s` instead of an integer `fd`. 2. `opendir()`, `readdir()`, and `closedir()` bypass the generic file descriptor table (`fs_files`), synthetic `g_dir_inode` / `g_dir_fileops`, and `struct uio` vectoring, resolving the target inode and invoking filesystem mount operations (`inode->u.i_mops->readdir`) directly. 3. Conformance features that depend on directory file descriptors (`dirfd`, `fdopendir`, `fchdir` on directory fds) can be cleanly conditionally compiled out under this option. I would love to help collaborate on this effort: - I can help prototype the conditional decoupling between `libs/libc/dirent/` and `fs/vfs/fs_dir.c`. - I can test and benchmark the linked flash savings (`.text`, `.data`, `.bss`) on `stm32f103-minimum:nsh` and verify directory operations on `sim:nsh` (e.g., `ls`, `cd`, recursive traversal). Let me know if you would like me to assist with prototyping this or if @jingfei195887 is already working on an initial draft! -- 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]
