Skip to content

[PHP] vfs: resolve pathname components across mounts#741

Merged
brandonpayton merged 1 commit into
integration/kd-6nz-php-phpt-platform-fixesfrom
gascity/kd-6nz/split-pr717-canonicalize-cwd-after-chdir
Jul 11, 2026
Merged

[PHP] vfs: resolve pathname components across mounts#741
brandonpayton merged 1 commit into
integration/kd-6nz-php-phpt-platform-fixesfrom
gascity/kd-6nz/split-pr717-canonicalize-cwd-after-chdir

Conversation

@brandonpayton

@brandonpayton brandonpayton commented Jun 20, 2026

Copy link
Copy Markdown
Member

Summary

Replace the unsafe lexical cwd-only fix with a component-wise global namespace resolver used before backend routing. Pathname syscalls now preserve symlink, ./.., missing-component, trailing-slash, mount-boundary, procfs/devfs, and AF_UNIX semantics instead of normalizing the input spelling before lookup.

This constituent is stacked on the open PHP platform aggregate, PR #871. It must not land independently on main; its syscall-visible semantic change remains covered by the aggregate ABI reconciliation and full gate.

Review of the original PR

The original commit (429390c8d) was not safe to replay. It validated one pathname and then lexically collapsed .., which can store a cwd different from the directory actually reached through a symlink. The same approach also broke missing/.., regular/., trailing slashes, VFS mount crossings, virtual namespaces, AF_UNIX registry aliases, and initial process cwd. The original commit was replaced, not retained as a misleading permanent intermediate commit.

Reviewed replacement

Replacement source commit: cc579aabb

  • Walk pathname components in the kernel's global namespace before selecting a host or synthetic backend.
  • Follow relative and absolute symlinks across mounts with a 40-link limit; preserve missing-component and trailing-directory error behavior.
  • Apply the resolver to ordinary and *at() pathname syscalls, cwd, realpath, statfs, exec paths, and AF_UNIX bind/connect/send paths.
  • Keep kernel-owned /proc and /dev names from falling through to hidden host entries while preserving the writable /dev/shm mount.
  • Store canonical global paths in cwd, OFDs, directory streams, and AF_UNIX registrations; re-key pathname sockets after rename.
  • Validate initial cwd through the same syscall path after installing child credentials, surface its errno to Node/browser hosts, and unregister a partially created process when startup fails.
  • Add kernel regressions plus a reusable guest probe exercised by Node and Chromium.
  • Document the remaining pathname-backed cwd/dirfd identity limitation instead of claiming inode identity after rename or unlink.

Remaining boundaries

  • Cwd and directory OFDs retain canonical pathnames, not stable directory identities. Rename/unlink followed by recreation can therefore redirect later getcwd, fchdir, or dirfd-relative behavior.
  • /proc/<pid>/fd/N magic links preserve final metadata but do not yet provide full OFD-identity traversal.
  • The legacy custom opendir stream API returns EOPNOTSUPP for synthetic procfs/devfs directories; normal open(O_DIRECTORY) plus getdents64 remains the supported path.

Validation on the reviewed tree

Run through scripts/dev-shell.sh unless noted:

  • cargo test -p kandelo --target aarch64-apple-darwin --lib1,102 passed, 0 failed.
  • cd host && npm run build — passed (ESM/CJS/type declarations built; existing import.meta CJS warnings only).
  • bash scripts/check-abi-version.sh — passed; structural snapshot and generated bindings are in sync.
  • cd host && npx vitest run test/node-host-mounts.test.ts12 passed, 0 failed, including cross-mount component resolution and both invalid-initial-cwd cleanup cases.
  • Isolated Chromium probe — 1 passed, 0 failed.
  • ./run.sh --fetch-only browser --host 127.0.0.1 --port 54742 --strictPort prepared the canonical browser path and launched Vite; the same Chromium probe against that live server passed 1/1.
  • git diff --check — clean.

The full host, libc, POSIX, Sortix, PHPT, and aggregate ABI/version gate remain intentionally deferred to PR #871's one ready-to-merge run.

Recommendation

Accept into PR #871. The replacement fixes a real platform-level pathname defect with Node/browser parity and truthful documented limits. Do not ship it independently or merge the aggregate until the aggregate ABI reconciliation is redesigned against the then-current main ABI and the full batch gate passes.

Walk path components in the kernel's global namespace before backend routing so symlinks, dot-dot, trailing slashes, virtual filesystems, mount crossings, and AF_UNIX pathnames share one canonical resolution model.

Validate initial cwd after installing child credentials, clean up failed registrations, and cover the behavior through kernel, Node, and Chromium probes. Cwd and directory OFDs remain pathname-backed after rename or unlink, as documented.

This changes syscall-visible pathname semantics inside the unmerged PHP platform batch; the aggregate ABI reconciliation remains required before the batch can land on main.
@brandonpayton
brandonpayton force-pushed the gascity/kd-6nz/split-pr717-canonicalize-cwd-after-chdir branch from 429390c to cc579aa Compare July 11, 2026 19:29
@brandonpayton brandonpayton changed the title [PHP] fix: canonicalize cwd after chdir [PHP] vfs: resolve pathname components across mounts Jul 11, 2026
@brandonpayton
brandonpayton changed the base branch from integration/kd-6nz-php-phpt-harness-only-base to integration/kd-6nz-php-phpt-platform-fixes July 11, 2026 19:29
@brandonpayton
brandonpayton merged commit 4ba585a into integration/kd-6nz-php-phpt-platform-fixes Jul 11, 2026
@brandonpayton
brandonpayton deleted the gascity/kd-6nz/split-pr717-canonicalize-cwd-after-chdir branch July 11, 2026 19:29
brandonpayton added a commit that referenced this pull request Jul 13, 2026
Component walking, symlink and mount traversal, error selection, and canonical initial/current-directory behavior change existing pathname semantics. Advance ABI 31 to 32 and regenerate ABI evidence atomically.

Source-PR: #741
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant