fix(libkernel): return EPERM when unlinking a directory #2289
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2289"
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-09T14:44:34Z.
What
FreeBSD's
unlink(2)fails withEPERMwhen the path is a directory.sceKernelUnlinkpassed the host error through, so the guest got a different code on each host:unlink("dir")onmain_wunlink)EACCES(13), measuredEPERM(1)unlink)EISDIR(21), perunlink(2)EPERM(1)sceKernelUnlinknow checks the path withsymlink_statusbefore unlinking and returnsEPERMfor a directory. A symbolic link to a directory is still unlinked, as on FreeBSD. If the path can't be inspected, the check doesn't match and the nativeunlinkreports its own error as before.unlink(the POSIX wrapper) goes throughsceKernelUnlink, so both are covered.Tested
Windows 11, WinLibs GCC 15.2.0 r7, Release,
-DBUILD_TESTING=ON:guest_filesystem_tests, next to the otherunlinkchecks:unlink(dir)returns -1 with errno 1 and leaves the directory in place, andsceKernelUnlink(dir)returns0x80020001. Onmainthe first fails withguest errno 13.ctest -R "guest_filesystem|guest_kernel_sync|guest_file": 3/3 passed.tools/check_conventions.pypasses, andtools/pr_overlap.py --branchreports no overlap. It also merges cleanly with #2144, #2170, #1628, #1777, #1755, #1764, #2193 and my #2260, which touch the same files (git merge-tree). #1727 already conflicts withmainon its own (TechnicalDebt.md).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-09T15:14:19Z.
Full Linux and Windows builds and tests for this head (
27516327), 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(d70b8998):ctest: 516/516 passedctest: 507/507 passedRun: https://github.com/AchrafReyani/AnyPS5/actions/runs/37946468349