fix(libkernel): report POSIX rename errors from sceKernelRename #2260
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2260"
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-09T13:35:03Z.
What
sceKernelRenamereturnedENOENTfor a missing source andEIOfor every other failure. On Windows the rename itself also went wrong: MinGW'sstd::filesystem::renamereports some missing paths asEIOand refuses to replace an existing empty directory, which FreeBSD'srename(2)does. Measured onmain(d70b8998) with libstdc++'sstd::filesystem::rename(generic category):std::filesystem::renamesceKernelRenameonmainrename(2)EIOENOENTENOENTEIOEIOENOENTEIOENOTDIREIOENOTDIREIOEISDIREACCESEIOENOTEMPTYEIOEIOEINVALEACCESEIORenameError_nid_no_patchchecks theserename(2)conditions before renaming and returns the guest error, the waysceKernelRmdiralready checks its own. On Windows it removes the empty target directory first, so the replace succeeds as on the console. A rename onto the same file, including a case-only rename on Windows, still goes straight tostd::filesystem::rename. Any other host failure is stillEIO.libc's
renamehas the same Windows behaviour (it callsstd::filesystem::renametoo). I left it alone because #1192 is moving that function into a new file; I can send the same fix for it afterwards.Tested
Windows 11, WinLibs GCC 15.2.0 r7, Release,
-DBUILD_TESTING=ON:New
sceKernelRenamechecks inguest_filesystem_tests, next to the libcrenamechecks:0x8002xxxxcodes;On
mainthe test fails on the first new check (guest errno 5).Mutation check: dropping the Windows empty-directory removal, or the subtree
EINVALcheck, each makeguest_filesystemfail.ctest -E "^agc_|video_out": 249/249 passed, includingguest_kernel_sync, which renames throughsceKernelRename.tools/check_conventions.pypasses, andtools/pr_overlap.py --branchreports no overlap. It also merges cleanly with #1192, #2170, #2115, #1620, #2129 and #2086, which touch the same files (git merge-tree).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 MarcZX10 on 2026-10-09T13:51:59Z.
I found one error-mapping case to resolve before approval.
symlink_status(source, error)andstatus(parent, error)seterrorwhen the path cannot be inspected (for example,permission_denied), but the helper only checksexists(status). A failed status then looks likefile_type::not_foundand is returned as guestENOENT, masking the actual access failure. Please inspecterrorbefore mapping a not-found status, preserve the applicable POSIX error (or the documentedEIOfallback), and add a regression where practical. The current PR checks skip full Linux/Windows Build, so they do not exercise this path.Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-09T13:58:47Z.
Full Linux and Windows builds and tests for this head (
ef5a4f3e), 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/37937885788
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T14:00:56Z.
Thanks for the exact-head fork Build report. The Linux 516/516 and Windows 507/507 suites plus the relinker matrix are useful evidence and close the general build/test gap. The specific status-inspection case I raised remains untested by the listed
sceKernelRenamecases: whensymlink_status(source, error)orstatus(parent, error)reports an inspection error, the helper still needs to distinguish that from a genuine not-found status before returning guestENOENT. I am keeping that focused finding open; the full suites do not currently exercise permission-denied metadata inspection.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T14:02:25Z.
Code review location:
core/libs/prx/libkernel/File/src/Stdio.cpp; line 638Could check
errorbefore treating!exists(sourceStatus)asENOENT?symlink_statuscan setpermission_deniedwhile the returned status isnot_found, so this branch conflates an inspection failure with a genuinely missing source. The destination-parent and destination status checks below have the same pattern. Please preserve the applicable guest error (or the documentedEIOfallback) when inspection fails.Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-09T14:43:34Z.
Good catch, thanks. Fixed in
2545929d:sceKernelRenamenow reads theerrorthatsymlink_status/statusset. libstdc++ also sets it for a plain miss (ENOENT/ENOTDIRwith typenot_found), so the mapping is:not_a_directory→ENOTDIR;not_found→ENOENT;permission_denied→EACCES;EIOfallback.perms::none. Renaming its entry and renaming into it must both return0x8002000Dand leave the files in place. Windows has no comparable way to deny traversal, so the block is#ifndef _WIN32.To show the test fails without the fix, I'm running it two ways on the fork's Build workflow: this head, and a control branch with only the new test on the previous head (
ef5a4f3e). I'll post both results here.Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-09T15:14:37Z.
Results for
2545929dand the control. Both ran the project'sbuild.yml(full builds plusctest) in my fork, merged intomaind70b8998:2545929def5a4f3eguest_filesystem—Filesystem check failed at line 148 (guest errno 13)#ifndef _WIN32)Line 148 is the new
perms::nonecheck. Without the inspection fix, a source the kernel couldn't stat came back asENOENTinstead ofEACCES. With it, both renames return0x8002000Dand the files stay where they were.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T20:10:48Z.
Closing: no title is shown stopping on
sceKernelRename's error codes or on the Windows empty-directory replace on main. Reopen with the title ID and the log line if one does.Pull request closed