fix(libkernel): unlink read-only files on Windows #2405
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2405"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-09T18:28:31Z.
What
This is the libkernel counterpart of #2342.
FreeBSD's
unlinkignores the file's own permission bits: what matters is write access to the directory. A guest that doeschmod(path, 0400)and thenunlink(path)orsceKernelUnlink(path)therefore succeeds on the console.On Windows, the guest
chmodsets the read-only attribute._wunlinkthen fails withEACCES, so both calls failed (0x8002000D/ errno 13) and the file stayed.NativeUnlink(Windows only) now handles that case. When_wunlinkfails withEACCESon a regular file without write permission, it makes the file writable with_wchmodand retries. If the retry fails too (e.g. the file is open without delete sharing), it puts the read-only attribute back and reports the retry's error, so a failed unlink leaves the file as it was. Only CRT calls already used in this file are needed (_wstat64,_wchmod); there is nowindows.h. Linux is unchanged.Tested
Windows 11, WinLibs GCC 15.2.0 r7, Release,
-DBUILD_TESTING=ON:guest_filesystem: two files made read-only withsceKernelChmod(0400)are removed, one byunlinkand one bysceKernelUnlink, and no longer exist.mainit fails at theunlinkline with guest errno 13.sceKernelUnlinkreturns0x8002000D, the file stays, and the read-only attribute is restored;sceKernelUnlinkremoves it.ctest -E "^agc_|video_out": 249/249.tools/check_conventions.pypasses, andtools/pr_overlap.py --branchreports no overlap.Open.cpporGuestFilesystem.cpp: #1620, #1624, #1628, #1755, #1764, #1777, #2086, #2115, #2129, #2144, #2170, #2193, #2260, #2289, #2300 and #2342. #1727 already conflicts withmaininTechnicalDebt.md, which this PR doesn't touch.A Linux and Windows full build will be posted here once it has run.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T18:28:42Z.
Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.
Pull request closed