fix(libkernel): allow delete sharing for open Windows files #3677

Merged
MarcZX10 merged 1 commit from upstream-pr/3677 into main 2026-10-11 21:49:26 +00:00
MarcZX10 commented 2026-10-11 15:13:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T15:13:04Z.


What

On Windows, sceKernelOpen currently uses _wopen without delete sharing. As a result, a guest cannot unlink an open file or rename an open source file, although those operations work on the Linux build and match the documented FreeBSD behavior. Open descriptors should continue to access the original file after its name is removed or moved, while a new file can take the old name.

This carries David Samir's commit from issue #3316, with the original commit author preserved. I rebased it onto current main and moved the added regression block earlier in GuestFilesystem.cpp to avoid the active test additions near the end of that file.

Open PR #2144 separately changes Windows scalar file error handling in Open.cpp; it does not implement delete sharing. The PRs touch the same file and should be rechecked/rebased if either merges first.

Tested

  • The issue author reports Windows 11 / WinLibs GCC 15.2 tests for the carried change: guest_filesystem passes 5/5, 3,276 _wopen comparison cases agree with the replacement, 50,000 open/close cycles retain the same timing, and a multithreaded create/write/unlink/recreate workload passes. Their full suite reports 770 passed and 5 skipped. These runs were on an earlier base and were not repeated here.
  • The issue author also reports Linux WSL2 / GCC 13.3 guest_filesystem passing 3/3 on the carried change. I did not rerun that target locally.
  • Locally: tools/check_conventions.py --base upstream/main and git diff --check pass.
  • Not tested here: Windows, native console behavior, or rename-over-existing-open-destination semantics. The latter remains outside this fix.

Checklist

  • Based on current main; no other open PR implements the same behavior
  • 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 in TechnicalDebt
  • 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
  • AI-assisted: yes (review, rebase, and PR preparation)

Fixes #3316

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4820058279 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3677). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-11T15:13:04Z. --- ### What On Windows, `sceKernelOpen` currently uses `_wopen` without delete sharing. As a result, a guest cannot unlink an open file or rename an open source file, although those operations work on the Linux build and match the documented FreeBSD behavior. Open descriptors should continue to access the original file after its name is removed or moved, while a new file can take the old name. This carries David Samir's commit from [issue #3316](https://github.com/boykopovar/AnyPS5/issues/3316), with the original commit author preserved. I rebased it onto current `main` and moved the added regression block earlier in `GuestFilesystem.cpp` to avoid the active test additions near the end of that file. Open PR #2144 separately changes Windows scalar file error handling in `Open.cpp`; it does not implement delete sharing. The PRs touch the same file and should be rechecked/rebased if either merges first. ### Tested - The issue author reports Windows 11 / WinLibs GCC 15.2 tests for the carried change: `guest_filesystem` passes 5/5, 3,276 `_wopen` comparison cases agree with the replacement, 50,000 open/close cycles retain the same timing, and a multithreaded create/write/unlink/recreate workload passes. Their full suite reports 770 passed and 5 skipped. These runs were on an earlier base and were not repeated here. - The issue author also reports Linux WSL2 / GCC 13.3 `guest_filesystem` passing 3/3 on the carried change. I did not rerun that target locally. - Locally: `tools/check_conventions.py --base upstream/main` and `git diff --check` pass. - Not tested here: Windows, native console behavior, or rename-over-existing-open-destination semantics. The latter remains outside this fix. ### Checklist - [x] Based on current `main`; no other open PR implements the same behavior - [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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes (review, rebase, and PR preparation) Fixes #3316
adriadam10 commented 2026-10-11 21:49:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T21:49:22Z.


Checked the CreateFileW replacement against the old _wopen behaviour: access mode, CREAT/EXCL/TRUNC dispositions, APPEND/BINARY flags passed to _open_osfhandle, read-only attribute from mode, inheritable handle, handle closed if _open_osfhandle fails. guest_filesystem passes on Linux and the conventions check is green. The Windows behaviour rests on the Windows 11 runs reported in #3316 (not reproducible here); merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6114177711 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3677#issuecomment-6114177711). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T21:49:22Z. --- Checked the `CreateFileW` replacement against the old `_wopen` behaviour: access mode, CREAT/EXCL/TRUNC dispositions, APPEND/BINARY flags passed to `_open_osfhandle`, read-only attribute from `mode`, inheritable handle, handle closed if `_open_osfhandle` fails. `guest_filesystem` passes on Linux and the conventions check is green. The Windows behaviour rests on the Windows 11 runs reported in #3316 (not reproducible here); merging.
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!3677
No description provided.