fix(libc): rename over a dangling symbolic link on macOS #9911

Merged
tkcm01 merged 1 commit from upstream-pr/9911 into main 2026-10-24 10:41:45 +00:00
tkcm01 commented 2026-10-22 21:25:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by tkcm01 on 2026-10-22T21:25:07Z.


What

RenamePath_nid_no_patch compares source and destination with fs::equivalent and clears ENOENT from it, so a destination that does not resolve counts as "not the same file". libc++ reports errc::not_supported instead of ENOENT when either path does not resolve, so on macOS rename of a file over a dangling symbolic link returned EIO (5) instead of replacing the link. guest_filesystem stops there (GuestFilesystem.cpp:871 on main: rename_nid_postfix(replacement, dangling), "Filesystem check failed … (guest errno 5, host errno 5)").

A path that does not resolve cannot be the same file as the other, so not_supported is cleared the same way, on macOS only. Linux and Windows are unchanged.

The same guard is part of the macOS ports in #7201 (@marion909) and #8658 (@iamthehimansh), both credited as co-authors; this splits it out as a small change, as for the rest of the macOS series on #1.

Tested

macOS 27.0.1, Apple M4, Apple clang 21, x86-64 build under Rosetta 2, no Vulkan loader. The libraries do not link on macOS from main alone, so the run is on mugurc's ci/macos-series-2 (53db0badb, main 3fd1cc393) with #7524, the code commits of #7937 and the libSceSsl change from #7332, as described on #1.

  • Before: guest_filesystem aborts at the dangling-symlink rename with guest and host errno 5.
  • After: it passes that check. The next check it stops at is sceKernelGetdents on a regular file (ENOTDIR instead of EINVAL), which is in the series' macOS sceKernelGetdirentries, not in main; with that also mapped locally, guest_filesystem passes. I've reported that one on #1.
  • Full ctest -j4: 1648 tests, 14 failed: the known macOS failures from my list on #1 minus guest_filesystem and guest_standard_streams (#8920 is in this tree), plus precise_wait, which is flaky here (it failed in my first baseline run too). No new failure.
  • python3 tools/check_conventions.py --base upstream/main: passed. tools/pr_overlap.py lists #5021, #7201 and #9693 for Rename.cpp; #7201 contains this change, #9693 changes SourceLookupError_nid_no_patch, and #5021's diff is too large for the API to compare. #9661 changes the two lines above this hunk.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4974331105 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9911). Originally posted by [tkcm01](https://github.com/tkcm01) on 2026-10-22T21:25:07Z. --- ### What `RenamePath_nid_no_patch` compares source and destination with `fs::equivalent` and clears `ENOENT` from it, so a destination that does not resolve counts as "not the same file". libc++ reports `errc::not_supported` instead of `ENOENT` when either path does not resolve, so on macOS `rename` of a file over a dangling symbolic link returned `EIO` (5) instead of replacing the link. `guest_filesystem` stops there (`GuestFilesystem.cpp:871` on `main`: `rename_nid_postfix(replacement, dangling)`, "Filesystem check failed … (guest errno 5, host errno 5)"). A path that does not resolve cannot be the same file as the other, so `not_supported` is cleared the same way, on macOS only. Linux and Windows are unchanged. The same guard is part of the macOS ports in #7201 (@marion909) and #8658 (@iamthehimansh), both credited as co-authors; this splits it out as a small change, as for the rest of the macOS series on #1. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> macOS 27.0.1, Apple M4, Apple clang 21, x86-64 build under Rosetta 2, no Vulkan loader. The libraries do not link on macOS from `main` alone, so the run is on mugurc's `ci/macos-series-2` (53db0badb, `main` 3fd1cc393) with #7524, the code commits of #7937 and the libSceSsl change from #7332, as described on #1. - Before: `guest_filesystem` aborts at the dangling-symlink rename with guest and host errno 5. - After: it passes that check. The next check it stops at is `sceKernelGetdents` on a regular file (`ENOTDIR` instead of `EINVAL`), which is in the series' macOS `sceKernelGetdirentries`, not in `main`; with that also mapped locally, `guest_filesystem` passes. I've reported that one on #1. - Full `ctest -j4`: 1648 tests, 14 failed: the known macOS failures from my list on #1 minus `guest_filesystem` and `guest_standard_streams` (#8920 is in this tree), plus `precise_wait`, which is flaky here (it failed in my first baseline run too). No new failure. - `python3 tools/check_conventions.py --base upstream/main`: passed. `tools/pr_overlap.py` lists #5021, #7201 and #9693 for `Rename.cpp`; #7201 contains this change, #9693 changes `SourceLookupError_nid_no_patch`, and #5021's diff is too large for the API to compare. #9661 changes the two lines above this hunk. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no --> 🤖 Generated with [Claude Code](https://claude.com/claude-code)
harisibrar1 commented 2026-10-23 03:21:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-23T03:21:03Z.

Review: APPROVED


Checked against main 3875f8c8ff, FreeBSD rename(2) and libc++ filesystem/operations.cpp (__equivalent):

  • FreeBSD's rename doesn't follow the destination's final component, so replacing a dangling link is the expected result.
  • libc++ equivalent reports errc::not_supported whenever either path's stat doesn't give an existing file, which explains the EIO on main. Clearing it is safe here because destinationExists already comes from symlink_status, and any real failure surfaces from the actual rename.
  • Optional nit: this is libc++ behaviour rather than Apple's, so #ifdef _LIBCPP_VERSION would describe the guard more precisely. Fine as is for the macOS series.
  • The branch still merges cleanly with current main.

Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5623511866 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9911#pullrequestreview-5623511866). Originally posted by [harisibrar1](https://github.com/harisibrar1) on 2026-10-23T03:21:03Z. **Review:** APPROVED --- Checked against main 3875f8c8ff, FreeBSD rename(2) and libc++ `filesystem/operations.cpp` (`__equivalent`): - FreeBSD's rename doesn't follow the destination's final component, so replacing a dangling link is the expected result. - libc++ `equivalent` reports `errc::not_supported` whenever either path's `stat` doesn't give an existing file, which explains the EIO on main. Clearing it is safe here because `destinationExists` already comes from `symlink_status`, and any real failure surfaces from the actual `rename`. - Optional nit: this is libc++ behaviour rather than Apple's, so `#ifdef _LIBCPP_VERSION` would describe the guard more precisely. Fine as is for the macOS series. - The branch still merges cleanly with current main. Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!9911
No description provided.