Skip to content

Conversation

@Gary-Hobson
Copy link
Contributor

Summary

This PR adds support for the FIOC_FILEPATH ioctl command in the FAT filesystem, enabling applications to retrieve the full path of an open file descriptor.

Implementation Details

Key features implemented:

  • fat_getfilepath(): Constructs file paths by traversing parent directories using ".." entries
  • fat_findlfnstart(): Helper function to locate the start of Long File Name (LFN) sequences
  • Supports both FAT12/16 and FAT32 filesystem types
  • Properly handles both regular directories and root directory traversal
  • Includes boundary checks and error handling for robustness

Use Cases

This functionality is valuable for:

  • Debugging and troubleshooting filesystem operations
  • Logging and audit trails that need full file paths
  • Applications that need to track or display file paths at runtime
  • Tools that introspect file descriptor information

Testing

The implementation has been tested on FAT32 filesystems and correctly handles:

  • Files in nested directories
  • Long file names (LFN)
  • Root directory files
  • Path reconstruction through parent directory traversal

@Gary-Hobson Gary-Hobson requested a review from acassis as a code owner January 22, 2026 11:53
@github-actions github-actions bot added Area: File System File System issues Size: M The size of the change in this PR is medium labels Jan 22, 2026
@acassis
Copy link
Contributor

acassis commented Jan 22, 2026

@Gary-Hobson please consider including a testing at apps/testing/fs/fat. We will need it to test all NuttX features later

Copy link
Contributor

@GUIDINGLI GUIDINGLI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use fatfs in your project, it is more recommend

@Gary-Hobson
Copy link
Contributor Author

why not use fatfs in your project, it is more recommend

fatfs is not included in the nuttx codebase.

@acassis
Copy link
Contributor

acassis commented Jan 22, 2026

@GUIDINGLI the FAT FS from NuttX was implemented from scratch by Greg, and although it could miss one or other feature from FatFS (exFAT is the most important one), NuttX implementation is better for low end devices and also since it is a different implementation some BUGs found on FatFS will not affect our implementation.

This patch adds support for the FIOC_FILEPATH ioctl command in the
FAT filesystem, allowing applications to retrieve the full path of
an open file descriptor.

Key features:
- Implements fat_getfilepath() to construct file paths by traversing
  parent directories using ".." entries
- Adds fat_findlfnstart() helper to locate the start of LFN sequences
- Supports both FAT12/16 and FAT32 filesystem types
- Handles both regular directories and root directory traversal

This functionality is useful for debugging, logging, and applications
that need to track file paths at runtime.

Signed-off-by: yinshengkai <yinshengkai@bytedance.com>
@acassis
Copy link
Contributor

acassis commented Jan 23, 2026

@Gary-Hobson please take a look at this error:

Configuration/Tool: sam3u-ek/knsh,CONFIG_ARM_TOOLCHAIN_GNU_EABI
2026-01-23 08:33:36
------------------------------------------------------------------------------------
  Cleaning...
  Configuring...
  Disabling CONFIG_ARM_TOOLCHAIN_BUILDROOT_OABI
  Enabling CONFIG_ARM_TOOLCHAIN_GNU_EABI
  Building NuttX...
arm-none-eabi-ld: /github/workspace/sources/nuttx/nuttx section `.data' will not fit in region `kflash'
arm-none-eabi-ld: region `kflash' overflowed by 356 bytes
make[1]: *** [Makefile:217: nuttx] Error 1
make: *** [tools/Unix.mk:542: nuttx] Error 2
make: Target 'all' not remade because of errors.
/github/workspace/sources/nuttx/tools/testbuild.sh: line 385: /github/workspace/sources/nuttx/../nuttx/nuttx.manifest: No such file or directory
  [1/1] Normalize sam3u-ek/knsh
/usr/bin/bash: line 1: arm-nuttx-elf-gcc: command not found
/usr/bin/bash: line 1: arm-nuttx-elf-gcc: command not found
HEAD detached at pull/18107/merge
Untracked files:
  (use "git add <file>..." to include in what will be committed)
	boards/arm/sam34/sam3u-ek/scripts/kernel-space.ld.tmp
	boards/arm/sam34/sam3u-ek/scripts/memory.ld.tmp

Seems like this PR increase the size of sam3u-ek

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: M The size of the change in this PR is medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants