Swatantra-66 opened a new pull request, #21862:
URL: https://github.com/apache/nuttx/pull/21862

   ## Summary
   
   Addresses #20414 by making the FIOC_FILEPATH ioctl and F_GETPATH fcntl 
command optional on small configurations (DEFAULT_SMALL=y).
   
   In small memory-constrained configurations, unconditionally handling 
`FIOC_FILEPATH` and `F_GETPATH` forces the inclusion of `inode_getpath()` and 
recursive path reconstruction logic even when no application or filesystem 
requires path resolution from open file descriptors.
   
   This PR introduces `CONFIG_FS_IOCTL_FILEPATH` (default `y` if 
`!DEFAULT_SMALL`, `default n`):
   1. `fs/Kconfig`: Defines `CONFIG_FS_IOCTL_FILEPATH`.
   2. `fs/vfs/Kconfig`: Selects `FS_IOCTL_FILEPATH` under `CONFIG_FS_NOTIFY` to 
preserve path resolution for filesystem notifications.
   3. `fs/vfs/fs_ioctl.c`: Rejects `FIOC_FILEPATH` with `-ENOTTY` prior to 
driver dispatch when disabled, and gates `inode_getpath()` fallback.
   4. `fs/vfs/fs_fcntl.c`: Keeps `F_GETPATH` case and returns `-ENOTTY` when 
disabled, matching `FIOC_FILEPATH`.
   5. `libs/libc/misc/lib_getfullpath.c`: Fixes `lib_getfullpath()` to properly 
propagate `fcntl(F_GETPATH)` error status (`-get_errno()`) instead of returning 
0 with an uninitialized buffer, ensuring caller `*at()` functions abort safely 
with `-ENOTTY` / `-ENOSYS`.
   
   ## Impact
   - **Is new feature added?:** Yes (`CONFIG_FS_IOCTL_FILEPATH`)
   - **Impact on user:** None when `CONFIG_FS_IOCTL_FILEPATH=y` (default for 
standard builds). For `DEFAULT_SMALL=y` builds, saves 240 bytes of Flash by 
excluding `inode_getpath()`.
   - **Impact on build:** None.
   - **Impact on hardware:** Reduced Flash footprint on microcontrollers.
   - **Impact on documentation:** Documented in Kconfig.
   
   ### Size Difference (Before vs After)
   Target: `stm32f103-minimum:nsh` (`DEFAULT_SMALL=y`)
   Compiler: `arm-none-eabi-gcc 10.3.1`
   
   **Before (master baseline):**
   ```
      text    data     bss     dec     hex filename
     53596     468    2992   57056    deea nuttx
   ```
   
   **After (with CONFIG_FS_IOCTL_FILEPATH=n):**
   ```
      text    data     bss     dec     hex filename
     53356     468    2992   56816    ddb0 nuttx
   ```
   
   **Difference:**
   - **.text:** -240 bytes (53,596 -> 53,356)
   - **.data:** 0 bytes
   - **.bss:** 0 bytes
   - **Flash savings:** **240 bytes (-0.45%)**
   - `inode_getpath()` is eliminated from the final binary image.
   
   Object file breakdown:
   - `fs/fs_ioctl.o`: 560 -> 464 bytes (-96 bytes)
   - `fs/fs_fcntl.o`: 392 -> 384 bytes (-8 bytes)
   
   ## Testing
   - **Host:** Linux Docker `nuttx-builder`
   - **Compiler:** `arm-none-eabi-gcc (15:10.3-2021.07-4) 10.3.1`
   - **Target:** `stm32f103-minimum:nsh` (`DEFAULT_SMALL=y`)
   
   ### Build Log:
   ```bash
   $ ./tools/configure.sh stm32f103-minimum:nsh
   Copy files
   Refreshing...
   configuration: stm32f103-minimum/nsh
   
   $ make -j
   ...
   CC:  fs_ioctl.c
   CC:  fs_fcntl.c
   CC:  lib_getfullpath.c
   LD:  nuttx
   CP:  nuttx.bin
   
   $ arm-none-eabi-size nuttx
      text    data     bss     dec     hex filename
     53356     468    2992   56816    ddb0 nuttx
   ```
   
   ### Style Verification:
   ```bash
   $ ./tools/checkpatch.sh -c -u -m -g HEAD~1..HEAD
   # 0 errors, 0 warnings
   ```
   


-- 
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]

Reply via email to