Skip to content

fs/vfs: make FIOC_FILEPATH and F_GETPATH optional for DEFAULT_SMALL - #21862

Merged
michallenc merged 1 commit into
apache:masterfrom
Swatantra-66:feature/vfs-optional-ioctl-filepath
Nov 17, 2026
Merged

michallenc merged 1 commit into
apache:masterfrom
Swatantra-66:feature/vfs-optional-ioctl-filepath

Conversation

@Swatantra-66

Copy link
Copy Markdown
Contributor

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:

$ ./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:

$ ./tools/checkpatch.sh -c -u -m -g HEAD~1..HEAD
# 0 errors, 0 warnings

@github-actions github-actions Bot added Area: File System File System issues Size: S The size of the change in this PR is small labels Nov 14, 2026
@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

MemBrowse Memory Report · Explore what changed →

arduino-mega2560

  • flash: .text -448 B (-0.7%, 67,764 B / 262,144 B, total: 26% used)

hifive1-revb

  • flash: .text -172 B (-0.2%, 87,244 B / 4,194,304 B, total: 2% used)

mirtoo

  • kseg0_progmem: .text -520 B (-0.7%, 69,192 B / 131,072 B, total: 53% used)

stm32-nucleo-f103rb

  • flash: .text -244 B (-0.7%, 35,608 B / 131,072 B, total: 27% used)

No memory changes detected for:


Catch memory regressions in CI with MemBrowse. Free for open source.

Comment thread fs/Kconfig Resolved
The FIOC_FILEPATH ioctl and F_GETPATH fcntl command resolve the path
of an open file descriptor from its inode tree. In small memory-constrained
configurations (DEFAULT_SMALL=y), unconditionally handling this command
forces the inclusion of inode_getpath() and path reconstruction logic,
adding unnecessary Flash overhead on targets that do not require path
resolution from file descriptors.

This patch introduces CONFIG_FS_IOCTL_FILEPATH (default !DEFAULT_SMALL):
1. In fs/Kconfig, defines CONFIG_FS_IOCTL_FILEPATH.
2. In fs/vfs/Kconfig, selects FS_IOCTL_FILEPATH under CONFIG_FS_NOTIFY.
3. In fs/vfs/fs_ioctl.c, rejects FIOC_FILEPATH with -ENOTTY prior to
   driver dispatch when disabled, and gates inode_getpath() fallback.
4. In fs/vfs/fs_fcntl.c, keeps F_GETPATH case and returns -ENOTTY when
   disabled, matching FIOC_FILEPATH behavior.
5. In libs/libc/misc/lib_getfullpath.c, properly propagates F_GETPATH
   failure (-get_errno()) so caller *at functions safely abort when
   path resolution is unsupported or fails, rather than operating on
   an uninitialized buffer.

Saves 240 bytes of Flash on stm32f103-minimum:nsh (text 53596 -> 53356 bytes).

Assisted-by: Google DeepMind:antigravity
Signed-off-by: Swatantra Yadav <[email protected]>
@Swatantra-66
Swatantra-66 force-pushed the feature/vfs-optional-ioctl-filepath branch from 39ef6d7 to 594e322 Compare November 16, 2026 07:04
@michallenc
michallenc merged commit 5d150b4 into apache:master Nov 17, 2026
53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: File System File System issues Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants