procfs: make stat() follow /proc/<pid>/fd links to live files#908
procfs: make stat() follow /proc/<pid>/fd links to live files#908brandonpayton wants to merge 1 commit into
Conversation
|
Independent exact-head review completed for
No review blocker was found. CI still owns full Vitest, browser, libc, POSIX, and Sortix coverage. |
|
Post-#907 integration evidence (no change to this PR's current head):
Landing plan: merge #907 first, then restack this existing PR to the equivalent post-#907 delta and rerun CI. Do not open or merge a second procfs PR. The port remains ABI-compatible. |
4535456 to
538d884
Compare
|
The pre-#913 staging run was intentionally cancelled after focused local and COI evidence passed. #913 has already promoted its future package generation into the shared ABI 39 index, so a fetch-only run from this PRs current pre-#913 base cannot materialize matching package inputs. After #913 merges, rebase #908 and rerun CI against the matching main/index generation; do not add a source-build fallback or weaken the index check. |
|
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. |
Purpose
Make
stat()on/proc/<pid>/fd/<number>report the metadata of the file that the descriptor actually has open.This is the Linux procfs contract:
lstat()orAT_SYMLINK_NOFOLLOWdescribes the procfs link itself.stat(), followingfstatat(), andstatx()describe the live open file behind that link.Tools such as
fusercompare device and inode values to find which process has a file open. Kandelo previously returned invented procfs regular-file metadata, so those tools could not match a descriptor to the real file.Root Cause
Kandelo already parsed
/proc/<pid>/fd/<number>as an fd link, but every procfs metadata request went throughprocfs_stat(). That function creates metadata for the synthetic procfs node; it never consulted the owning process's descriptor table or open-file-description table.The wrong result came from kernel state handling, not from the
fuserpackage or Homebrew.What Changed
stat,fstatat, andstatxrequests use the same live metadata asfstat(fd).lstatandAT_SYMLINK_NOFOLLOWreporting a symlink.ENOENTafter the process disappears or the descriptor closes.There is no package-specific behavior in this change.
ABI
No ABI bump is required. This corrects the result of existing stat-family syscalls without changing syscall numbers, arguments, marshalling, pointer interpretation, exported functions, layouts, or binary expectations. Existing ABI 39 programs already request this behavior through the current interface.
ABI_VERSIONremains 39.abi/snapshot.json, the generated C header, and the generated TypeScript bindings are unchanged.scripts/check-abi-version.shpasses on this head.Merge Order
main.Do not merge #908 before #913. PR #913's prepared package artifacts were generated from the current main branch. This procfs fix is intentionally separate and does not need to be absorbed into that package batch.
Validation
Current tested head:
538d884c1, based on exact main9a7a67919.Run through
scripts/dev-shell.sh:cargo test -p kandelo --target aarch64-apple-darwin --lib procfs_fd_stat_follows_the_live_ofd: 1/1 passed.cargo build --release -p kandelo -Z build-std=core,alloc: passed.programs/procfs-foreign-fd-stat.c: passed.npx vitest run --root . test/procfs-fd-stat.test.tsfromhost/, after removinghost/dist: 1/1 passed on the final commit.npx playwright test test/procfs-fd-stat.spec.ts --project=chromiumfromapps/browser-demos/, on a fresh non-reused Vite port: 1/1 passed on the final commit.bash scripts/check-abi-version.sh: passed; ABI snapshot and generated bindings are in sync.git diff --check: passed.9260b569d: only Prettier wrapping changed; kernel, guest, browser, and documentation semantics are identical.The full kernel, Vitest, browser, libc, POSIX, and Sortix suites were not rerun locally; CI owns those broad gates. The declared dev shell does not currently include
cargo-fmt, so the local Rust formatting command could not run; CI will provide the authoritative formatting result.