You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "casaroli (via GitHub)" <gi...@apache.org> on 2026/10/09 12:17:23 UTC
[PR] fs/vfs: Make fstat() of an open directory describe the directory. [nuttx]
casaroli opened a new pull request, #20559:
URL: https://github.com/apache/nuttx/pull/20559
## Summary
`open()` of a directory gives the file a stand-in inode, `g_dir_inode`, with the directory operations. `file_fstat()` did not know it and returned `inode_stat()` of that stand-in: a directory, but with `st_ino` 0 and none of the real directory's attributes, on every file system.
Programs that walk directories with `openat()` and `fstat()`, for example with fts, compare `st_dev` and `st_ino` with those from `stat()` to detect loops and changed directories. They failed: a recursive `ls` reported each subdirectory as "already listed", and a recursive `rm` stopped with a traversal error.
This PR stats the directory by the path that the open directory keeps (the same path that `F_GETPATH` returns).
## Impact
`fstat()` of a file descriptor that `open()` returned for a directory. Other descriptors are unchanged.
## Testing
`qemu-armv8a:knsh` with a virtio 9P share mounted at `/mnt`, QEMU 11. The test program was built outside the tree against the export package.
A program compares `stat()` of a directory with `fstat()` of the directory opened with `open(path, O_RDONLY | O_DIRECTORY)`:
Before:
```
/mnt/d stat: dir=1 ino=170158369 fstat: dir=1 ino=0
/mnt/d/e stat: dir=1 ino=170158371 fstat: dir=1 ino=0
```
After:
```
/mnt/d stat: dir=1 ino=170158369 fstat: dir=1 ino=170158369
/mnt/d/e stat: dir=1 ino=170158371 fstat: dir=1 ino=170158371
```
Builds with `-Wno-cpp -Werror`: `qemu-armv8a:knsh`, `lm3s6965-ek:qemu-flat`, `mps2-an500:nsh`, `rv-virt:knsh`, `raspberrypi-pico:nsh`. `tools/checkpatch.sh -c -u -m -g` passes.
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fs/vfs: Make fstat() of an open directory describe the directory. [nuttx]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #20559:
URL: https://github.com/apache/nuttx/pull/20559#issuecomment-6082545456
<!-- membrowse-pr-comment -->
## <img src="https://membrowse.com/membrowse-logo.svg" height="24" align="top"> MemBrowse Memory Report
### [arduino-mega2560](https://membrowse.com/public/apache/nuttx/target/arduino-mega2560/compare?head=451c70f85a7f4c0b37ebce9fea2864da78ca373f&base=dcc3b7b384f9ea35c23371884645b428435fb716)
- **flash**: .text +628 B (+1.0%, 65,916 B / 262,144 B, total: 25% used)
### [esp32-devkitc](https://membrowse.com/public/apache/nuttx/target/esp32-devkitc/compare?head=451c70f85a7f4c0b37ebce9fea2864da78ca373f&base=dcc3b7b384f9ea35c23371884645b428435fb716)
- **ROM**: .flash.text +52 B (+0.0%, 125,016 B / 4,194,272 B, total: 3% used)
- **irom0_0_seg**: .flash.text +52 B (+0.1%, 89,220 B / 3,342,304 B, total: 3% used)
### [rx65n-rsk2mb](https://membrowse.com/public/apache/nuttx/target/rx65n-rsk2mb/compare?head=451c70f85a7f4c0b37ebce9fea2864da78ca373f&base=dcc3b7b384f9ea35c23371884645b428435fb716)
- **ROM**: .text +16 B (+0.0%, 86,944 B / 2,097,152 B, total: 4% used)
### [s698pm-dkit](https://membrowse.com/public/apache/nuttx/target/s698pm-dkit/compare?head=451c70f85a7f4c0b37ebce9fea2864da78ca373f&base=dcc3b7b384f9ea35c23371884645b428435fb716)
- **Code**: .text +160 B (+0.0%, 373,040 B)
*No memory changes detected for:*
- [hifive1-revb](https://membrowse.com/public/apache/nuttx/target/hifive1-revb/compare?head=451c70f85a7f4c0b37ebce9fea2864da78ca373f&base=dcc3b7b384f9ea35c23371884645b428435fb716)
- [mirtoo](https://membrowse.com/public/apache/nuttx/target/mirtoo/compare?head=451c70f85a7f4c0b37ebce9fea2864da78ca373f&base=dcc3b7b384f9ea35c23371884645b428435fb716)
- [qemu-armv8a](https://membrowse.com/public/apache/nuttx/target/qemu-armv8a/compare?head=451c70f85a7f4c0b37ebce9fea2864da78ca373f&base=dcc3b7b384f9ea35c23371884645b428435fb716)
- [qemu-intel64](https://membrowse.com/public/apache/nuttx/target/qemu-intel64/compare?head=451c70f85a7f4c0b37ebce9fea2864da78ca373f&base=dcc3b7b384f9ea35c23371884645b428435fb716)
- [stm32-nucleo-f103rb](https://membrowse.com/public/apache/nuttx/target/stm32-nucleo-f103rb/compare?head=451c70f85a7f4c0b37ebce9fea2864da78ca373f&base=dcc3b7b384f9ea35c23371884645b428435fb716)
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fs/vfs: Make fstat() of an open directory describe the directory. [nuttx]
Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on PR #20559:
URL: https://github.com/apache/nuttx/pull/20559#issuecomment-6107211044
@casaroli could you create a new patch to fix the warning:
```
====================================================================================
Configuration/Tool: fvp-armv8r/nsh
2026-10-10 22:43:09
------------------------------------------------------------------------------------
Cleaning...
Configuring...
Building NuttX...
Makefile:142: target 'arm64_perf.o' given more than once in the same rule
Makefile:142: target 'arm64_perf.o' given more than once in the same rule
Makefile:142: target 'arm64_perf.o' given more than once in the same rule
Makefile:142: target 'arm64_perf.o' given more than once in the same rule
Makefile:142: target 'arm64_perf.o' given more than once in the same rule
```
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fs/vfs: Make fstat() of an open directory describe the directory. [nuttx]
Posted by "casaroli (via GitHub)" <gi...@apache.org>.
casaroli closed pull request #20559: fs/vfs: Make fstat() of an open directory describe the directory.
URL: https://github.com/apache/nuttx/pull/20559
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fs/vfs: Make fstat() of an open directory describe the directory. [nuttx]
Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on PR #20559:
URL: https://github.com/apache/nuttx/pull/20559#issuecomment-6127517425
> @xiaoxiang781216 I opened #20606 for the arm64_perf.o warning (merged now). The flat build no longer adds the user copy, and the arm64 object rules drop duplicate names (pnsh warned too).
>
> The qemu-armv8a citest failure came from the ostest rr_test defaults. apps #3832 reverted them on 2026-10-11, and the re-run passes.
@casaroli thanks!
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fs/vfs: Make fstat() of an open directory describe the directory. [nuttx]
Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis merged PR #20559:
URL: https://github.com/apache/nuttx/pull/20559
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fs/vfs: Make fstat() of an open directory describe the directory. [nuttx]
Posted by "casaroli (via GitHub)" <gi...@apache.org>.
casaroli commented on PR #20559:
URL: https://github.com/apache/nuttx/pull/20559#issuecomment-6124458066
@xiaoxiang781216 I opened #20606 for the arm64_perf.o warning (merged now). The flat build no longer adds the user copy, and the arm64 object rules drop duplicate names (pnsh warned too).
The qemu-armv8a citest failure came from the ostest rr_test defaults. apps #3832 reverted them on 2026-10-11, and the re-run passes.
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fs/vfs: Make fstat() of an open directory describe the directory. [nuttx]
Posted by "casaroli (via GitHub)" <gi...@apache.org>.
casaroli commented on code in PR #20559:
URL: https://github.com/apache/nuttx/pull/20559#discussion_r4239302154
##########
fs/vfs/fs_fstat.c:
##########
@@ -180,6 +180,16 @@ int file_fstat(FAR struct file *filep, FAR struct stat *buf)
return -EBADF;
}
+ /* A directory opened with open() has a stand-in inode; stat the
+ * directory itself.
+ */
+
+ ret = dir_fstat(filep, buf);
Review Comment:
done
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fs/vfs: Make fstat() of an open directory describe the directory. [nuttx]
Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #20559:
URL: https://github.com/apache/nuttx/pull/20559#discussion_r4234548513
##########
fs/vfs/fs_fstat.c:
##########
@@ -180,6 +180,16 @@ int file_fstat(FAR struct file *filep, FAR struct stat *buf)
return -EBADF;
}
+ /* A directory opened with open() has a stand-in inode; stat the
+ * directory itself.
+ */
+
+ ret = dir_fstat(filep, buf);
Review Comment:
should we move after line 223
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fs/vfs: Make fstat() of an open directory describe the directory. [nuttx]
Posted by "casaroli (via GitHub)" <gi...@apache.org>.
casaroli closed pull request #20559: fs/vfs: Make fstat() of an open directory describe the directory.
URL: https://github.com/apache/nuttx/pull/20559
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org