kernel: make fstatat empty-path handling match Linux - #865
Closed
brandonpayton wants to merge 1 commit into
Closed
Conversation
Implement Linux AT_EMPTY_PATH semantics for both open descriptors and AT_FDCWD, return ENOENT when the flag is absent, and reject unsupported fstatat/statx flags without rejecting statx synchronization modes. Add kernel coverage and wasm32/wasm64 guest ABI regression tests.
brandonpayton
force-pushed
the
fix/fstatat-empty-path
branch
from
July 15, 2026 05:07
d4c94ea to
590a990
Compare
Member
Author
|
Absorbed by rebase-merged #967. Main is now 6efb411 with the sealed tree b133bfa018f7e2bc84c4845edf2f945b2f844954, and ABI 41 activation completed successfully in run 29550069085. The absorption audit confirmed this PR\x27s behavior and tests are present in that merged tree, so this source PR is closed and its branch is deleted. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The fstatat and statx system calls return file metadata. Linux's AT_EMPTY_PATH flag means that an empty pathname refers to an already-open file descriptor instead of a named path. Ruby uses this behavior when checking Homebrew download locks.
Make
fstatatandstatxhandle Linux empty-path requests correctly. This is the path used by Ruby'sFile#stat/IO#stat, and therefore by Homebrew's download-lock code inside Kandelo.Before this fix, Kandelo sent an empty pathname through ordinary path resolution. A regular-file descriptor then failed instead of statting the open file, so Homebrew aborted before downloading a package.
Root cause
sys_fstatatdid not implementAT_EMPTY_PATHand did not validate its flags. The earlier version of this PR only special-cased a non-AT_FDCWDdescriptor; against currentmain, that left the cwd form wrong, preserved the wrong no-flag errno, and silently accepted invalid flags.What changed
fstatat(fd, "", ..., AT_EMPTY_PATH)stats the open descriptor itself, including non-directory descriptors such as regular files and pipes.fstatat(AT_FDCWD, "", ..., AT_EMPTY_PATH)stats the current working directory.AT_EMPTY_PATHreturnsENOENT.fstatatflags returnEINVAL;AT_NO_AUTOMOUNTremains an accepted no-op.statxaccepts either synchronization selector, rejects selecting both, and passes the remaining lookup flags through the same checked path.fstatat/statxas partial because Kandelo still represents cwd and directory OFDs by pathname after rename/unlink. This PR does not hide that broader directory-identity limitation.This is a platform fix, not Homebrew-specific behavior.
ABI impact
No ABI bump is required. The syscall numbers, marshalling, structures, channel layout, exports, and guest constants are unchanged; existing binaries receive corrected behavior.
Exact-head validation
Current head:
590a9905aa48ade43784dceb496a7dbf4be28d47fstatatempty-path tests passed, covering descriptor/cwd targets and Linux error behavior.statxsynchronization-flag test passed.scripts/dev-shell.sh.scripts/check-abi-version.shpassed at ABI 39; snapshot and generated bindings remain synchronized.git diff --checkpassed.The original Homebrew download-lock symptom was not rerun end to end on this exact head. The new guest regression exercises the same public
fstatatcall and errno contract directly.Fresh hosted staging, browser, kernel, host, libc, POSIX, and Sortix gates are required on this rewritten current-main head before
ready-to-shipis applied. The old ABI-16-base run is not merge evidence for this version.