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/17 21:54:49 UTC
[PR] libs/libc/misc: Return ENOENT for an empty path in the *at() functions. [nuttx]
casaroli opened a new pull request, #20752:
URL: https://github.com/apache/nuttx/pull/20752
## Summary
POSIX says that an empty path names no file, so the call fails with `ENOENT`. `access("")`, `stat("")`, `lstat("")` and `open("")` already do this. The `*at()` functions did not: `lib_getfullpath()` turned `""` into the directory itself (`$PWD/` or the path of `dirfd`). So `faccessat(AT_FDCWD, "", X_OK)` returned 0, `fstatat(AT_FDCWD, "", 0)` returned the current directory, and `openat(AT_FDCWD, "")` failed with `ENXIO`.
- The second commit makes `lib_getfullpath()` return `-ENOENT` for `""`. This fixes all `*at()` functions at once: `faccessat`, `fstatat`, `openat`, `mkdirat`, `unlinkat`, `fchownat`, `linkat`, `symlinkat`, `readlinkat`, `utimensat`, `renameat`, `mkfifoat` and `mknodat`.
- `fstatat(fd, "", AT_EMPTY_PATH)` worked only because of that bug. The first commit makes `fstatat()` handle `AT_EMPTY_PATH` itself (`fstat(dirfd)`, or `"."` for `AT_FDCWD`), so it keeps working.
## Impact
The `*at()` functions now fail with `ENOENT` for an empty path, as POSIX requires. `fstatat()` with `AT_EMPTY_PATH` does not change.
## Testing
A test program on `qemu-armv8a:knsh` (QEMU 11 with HVF on an Apple M4):
| Check | master | this PR |
|---|---|---|
| `access("")`, `stat("")`, `lstat("")`, `open("")` | `ENOENT` | `ENOENT` |
| `faccessat(AT_FDCWD, "")` | 0 | `ENOENT` |
| `fstatat(AT_FDCWD, "", 0)` | 0 | `ENOENT` |
| `fstatat(dirfd, "", 0)` | 0 | `ENOENT` |
| `openat(AT_FDCWD, "")` | `ENXIO` | `ENOENT` |
| `fstatat()` with `AT_EMPTY_PATH` (`AT_FDCWD`, a directory fd, a file fd) | ok | ok |
`ostest` on `qemu-armv8a:knsh` and `qemu-armv8a:nsh` ends with `ostest_main: Exiting with status 0`. `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] libs/libc/misc: Return ENOENT for an empty path in the *at() functions. [nuttx]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #20752:
URL: https://github.com/apache/nuttx/pull/20752#issuecomment-6241892643
<!-- membrowse-pr-comment -->
## <img src="https://membrowse.com/membrowse-logo.svg" height="24" align="top"> MemBrowse Memory Report
*No memory changes detected for:*
- [arduino-mega2560](https://membrowse.com/public/apache/nuttx/target/arduino-mega2560/compare?head=57246d12dfb521d8397c55f02254e3e13fb98fe3&base=d2ce23c49ebfdd9f5ed541a08493eb62c1aa20a5)
- [esp32-devkitc](https://membrowse.com/public/apache/nuttx/target/esp32-devkitc/compare?head=57246d12dfb521d8397c55f02254e3e13fb98fe3&base=d2ce23c49ebfdd9f5ed541a08493eb62c1aa20a5)
- [hifive1-revb](https://membrowse.com/public/apache/nuttx/target/hifive1-revb/compare?head=57246d12dfb521d8397c55f02254e3e13fb98fe3&base=d2ce23c49ebfdd9f5ed541a08493eb62c1aa20a5)
- [mirtoo](https://membrowse.com/public/apache/nuttx/target/mirtoo/compare?head=57246d12dfb521d8397c55f02254e3e13fb98fe3&base=d2ce23c49ebfdd9f5ed541a08493eb62c1aa20a5)
- [qemu-armv8a](https://membrowse.com/public/apache/nuttx/target/qemu-armv8a/compare?head=57246d12dfb521d8397c55f02254e3e13fb98fe3&base=d2ce23c49ebfdd9f5ed541a08493eb62c1aa20a5)
- [qemu-intel64](https://membrowse.com/public/apache/nuttx/target/qemu-intel64/compare?head=57246d12dfb521d8397c55f02254e3e13fb98fe3&base=d2ce23c49ebfdd9f5ed541a08493eb62c1aa20a5)
- [rx65n-rsk2mb](https://membrowse.com/public/apache/nuttx/target/rx65n-rsk2mb/compare?head=57246d12dfb521d8397c55f02254e3e13fb98fe3&base=d2ce23c49ebfdd9f5ed541a08493eb62c1aa20a5)
- [s698pm-dkit](https://membrowse.com/public/apache/nuttx/target/s698pm-dkit/compare?head=57246d12dfb521d8397c55f02254e3e13fb98fe3&base=d2ce23c49ebfdd9f5ed541a08493eb62c1aa20a5)
- [stm32-nucleo-f103rb](https://membrowse.com/public/apache/nuttx/target/stm32-nucleo-f103rb/compare?head=57246d12dfb521d8397c55f02254e3e13fb98fe3&base=d2ce23c49ebfdd9f5ed541a08493eb62c1aa20a5)
--
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] libs/libc/misc: Return ENOENT for an empty path in the *at() functions. [nuttx]
Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis merged PR #20752:
URL: https://github.com/apache/nuttx/pull/20752
--
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