fix(libkernel): remove a Windows directory junction without emptying its target #7530

Closed
mazen320 wants to merge 1 commit from upstream-pr/7530 into main
mazen320 commented 2026-10-18 12:28:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-18T12:28:38Z.


What

rmdir of a Windows directory junction followed the target. When the target held a file, rmdir and sceKernelRmdir returned ENOTEMPTY and left the junction. unlink and sceKernelUnlink treated the junction as a directory and returned EPERM.

A drive-absolute directory junction now gets ENOTDIR from rmdir without inspecting the target. unlink removes only the junction and leaves the target, including when the target is not empty. A volume mount whose substitute name is a Volume GUID, and any other reparse point, stay on the previous path.

Tested

Windows 11, WinLibs GCC 15.2.0, unelevated. guest_filesystem (ctest #1200) passed, including a junction whose target contains a file. Conventions passed against upstream/main. GitHub Windows and Linux CI were not run.

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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4909086136 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7530). Originally posted by [mazen320](https://github.com/mazen320) on 2026-10-18T12:28:38Z. --- ### What `rmdir` of a Windows directory junction followed the target. When the target held a file, `rmdir` and `sceKernelRmdir` returned `ENOTEMPTY` and left the junction. `unlink` and `sceKernelUnlink` treated the junction as a directory and returned `EPERM`. A drive-absolute directory junction now gets `ENOTDIR` from `rmdir` without inspecting the target. `unlink` removes only the junction and leaves the target, including when the target is not empty. A volume mount whose substitute name is a Volume GUID, and any other reparse point, stay on the previous path. ### Tested Windows 11, WinLibs GCC 15.2.0, unelevated. `guest_filesystem` (ctest #1200) passed, including a junction whose target contains a file. Conventions passed against `upstream/main`. GitHub Windows and Linux CI were not run. ### Checklist - [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 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
TheTerr4 commented 2026-10-18 14:59:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TheTerr4 on 2026-10-18T14:59:36Z.


Windows runtime check. Windows 11 Pro 10.0.26200, Ryzen 7 7800X3D, WinLibs GCC 15.2.0 r7 (UCRT), Release.

This PR's head b40234c7d merged cleanly into main 385ed71f2; the full build and libs both exit 0.

  • guest_filesystem, guest_posix_filesystem and guest_kernel_sys pass, three repeated -j1 runs.
  • Negative control: with libkernel/File/src/Open.cpp and Stdio.cpp restored to main's versions, guest_filesystem aborts (exit 0xc0000409).
  • Not run: the full suite, Linux, macOS. The symlink cases in guest_filesystem are skipped on this machine (Developer Mode is off); the junction cases ran.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6251390850 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7530#issuecomment-6251390850). Originally posted by [TheTerr4](https://github.com/TheTerr4) on 2026-10-18T14:59:36Z. --- Windows runtime check. Windows 11 Pro 10.0.26200, Ryzen 7 7800X3D, WinLibs GCC 15.2.0 r7 (UCRT), Release. This PR's head `b40234c7d` merged cleanly into `main` `385ed71f2`; the full build and `libs` both exit 0. - `guest_filesystem`, `guest_posix_filesystem` and `guest_kernel_sys` pass, three repeated `-j1` runs. - Negative control: with `libkernel/File/src/Open.cpp` and `Stdio.cpp` restored to `main`'s versions, `guest_filesystem` aborts (exit 0xc0000409). - Not run: the full suite, Linux, macOS. The symlink cases in `guest_filesystem` are skipped on this machine (Developer Mode is off); the junction cases ran. AI-assisted: yes (Claude Code).
mazen320 commented 2026-10-21 06:51:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-21T06:51:38Z.


Rebased onto current main. Kept PathLookupFailure after the symlink check and merged the junction rmdir/unlink debt note with the existing O_NOFOLLOW sentence.

Local tip de097ab0c: guest_filesystem passed.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6309957271 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7530#issuecomment-6309957271). Originally posted by [mazen320](https://github.com/mazen320) on 2026-10-21T06:51:38Z. --- Rebased onto current `main`. Kept `PathLookupFailure` after the symlink check and merged the junction `rmdir`/`unlink` debt note with the existing `O_NOFOLLOW` sentence. Local tip `de097ab0c`: `guest_filesystem` passed.

Pull request closed

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!7530
No description provided.