Repository navigation
fix(libkernel): allow delete sharing for open Windows files - #3677
Merged
adriadam10 merged 1 commit intoOct 11, 2026
Merged
Conversation
…ndows FreeBSD removes or renames a file that is still open; the descriptor stays usable. _wopen opens without FILE_SHARE_DELETE, so sceKernelUnlink returned EACCES and rename failed while the guest held a descriptor. sceKernelOpen now opens through CreateFileW with delete sharing and keeps the flag, mode and error mapping of _wopen. (cherry picked from commit 2f5ada5)
9 tasks done
Collaborator
|
Checked the |
9 tasks done
oneandonlydean
pushed a commit
that referenced
this pull request
Oct 12, 2026
fopen opened its stream with _wfopen, which shares read and write access but not delete access. While the guest held a stream open, rename of its file failed with EIO and remove with EBUSY. POSIX rename and remove work on open files, as on Linux and FreeBSD, and since #3677 the descriptors sceKernelOpen returns share delete access. fopen now creates the handle with CreateFileW sharing read, write and delete, with the access and creation disposition of the mode, and wraps it with _open_osfhandle and _wfdopen, keeping append mode. A failed CreateFileW sets errno through the error mapping #3677 added to libkernel's NativeOpen, which moves to libc as WindowsOpenError_nid_no_patch so that both use it. freopen still reopens through _wfreopen; TechnicalDebt records it.
10 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
On Windows,
sceKernelOpencurrently uses_wopenwithout 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
mainand moved the added regression block earlier inGuestFilesystem.cppto 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
guest_filesystempasses 5/5, 3,276_wopencomparison 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.guest_filesystempassing 3/3 on the carried change. I did not rerun that target locally.tools/check_conventions.py --base upstream/mainandgit diff --checkpass.Checklist
main; no other open PR implements the same behaviorNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Fixes #3316