fix(libkernel): unlink read-only files on Windows #2910
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2910"
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-10T18:23:46Z.
What
Fixes #2601. This is the libkernel counterpart of #2342.
FreeBSD's
unlinkignores the file's own permission bits, sochmod(path, 0400)followed byunlink(path)succeeds on the console. On Windows, the guestchmodsetsFILE_ATTRIBUTE_READONLY, and_wunlinkthen failed withEACCES. Sounlinkreturned -1 with errno 13,sceKernelUnlinkreturned0x8002000D, and the file stayed.NativeUnlink(Windows only) now decides up front, the shape requested on #2342, with no retry. When_wstat64reports a regular file without_S_IWRITE, it makes the file writable with_wchmodbefore the single_wunlink. If the unlink fails, for example because the file is open without delete sharing, it restores the read-only attribute and reports the unlink's error. The change uses only CRT calls already inOpen.cpp. Linux is unchanged.Tested
guest_filesystemgains two files made read-only withsceKernelChmod(0400): one removed withunlink, one withsceKernelUnlink. Both must no longer exist.mainbf6e25a1):guest_filesystempasses 3/3. Earlier, on89a1fb4e:Open.cppchange (guest errno 13);0x8002000D, stayed in place and kept its read-only attribute; after the handle was closed, it was removed;ctest -E "^agc_|video_out"passed 341/341.b5f5362d(#2601): fails without theOpen.cppchange, passes with it.b5f5362dandcf8b129e(#2601):guest_filesystempasses.check_conventions.pypasses, andpr_overlap.py --branchreports no overlap.#2651 (open) targets the same behaviour; see the coordination comments there and on #2601.
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 reyani-dev on 2026-10-10T19:06:47Z.
Full Linux and Windows builds and tests for this head (
f45d8933), using the project's Build workflow. I can't start the upstream manual run, so I ran the samebuild.ymlin my fork through a mirror PR. Like the upstream run, the jobs check out the PR head merged into currentmain(bf6e25a1):ctest: 701/701 passedctest: 709/709 passedRun: https://github.com/AchrafReyani/AnyPS5/actions/runs/38075637171