fix(libc): report a status error of the rename parent directory instead of ENOENT or ENOTDIR #8217
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8217"
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 xXPBSXx on 2026-10-20T03:58:13Z.
What
Follow-up to #8174 after MarcZX10's review there.
RenameDotErrorincore/libs/prx/libc/include/RenameDot.hppclassified the parent directory withexists()andis_directory()taking anerror_code, which both return false for a missing path and for an error such as permission denied; the code answeredENOENTorENOTDIRfor both and hid the real error. It now reads the parent withstatus(): a missing path isENOENT(ENOTDIRwhen the status reportsnot_a_directory), any other status error goes throughFilesystemError(status), and only a successful status decides between a directory (EINVAL) and a non-directory (ENOTDIR).Fixes: none (review of #8174)
Tested
Windows 10 (19045), MinGW-w64 GCC 15.2.0, Release, on
upstream/main+ this commit:guest_rename_dotandguest_filesystempass (2 of 2).python tools/check_conventions.py --base upstream/main: passes.status()of a parent fail with something other than "not found" (permission denied needs an ACL setup the test cannot assume), so this is a code-level correction.Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repositoryAI-assisted (Claude Code).
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by wachi35676 on 2026-10-20T11:29:43Z.
On Linux this change is observable, so the missing negative test can be written. Head
903f73a3amerged ontomain02fb1ce53. A probe callsrename_nid_postfix(from, "target")with relative paths, from a directory that holdsdir/,file.txtand a symbolic-link looploop -> loop.frommainmainfile.txt/.file.txt/..file.txt/sub/.loop/.missing/.,missing/sub/.dir/.,dir/..BUILD_TESTING=ON. Windows: Windows 11 (10.0.26300), WinLibs GCC 15.2.0 UCRT, Release.guest_rename_dotpasses on both hosts, andguest_filesystempasses on Windows (2 runs each). The existing test passes with or without the change, so it does not cover the new branches.file.txt/.(ENOTDIR) andloop/.(ELOOP) on Linux fail onmainand pass with this change. Neither needs ACLs or root, so they could go intoGuestRenameDot.cppunder#ifndef _WIN32.file.txt/sub/.is still ENOENT, because MinGW'sstatus()reports a path under a regular file as not found rather thannot_a_directory. That is unchanged frommain, but the description's "ENOTDIRwhen the status reportsnot_a_directory" does not cover Windows.AI-assisted: yes (Claude Code); results above were run on this machine.
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-20T12:29:02Z.
Thanks for the Linux data and the table. I added the two cases you named (
file.txt/.andloop/.) in34acda342('cover rename through a file and through a symbolic link loop'), somainnow fails them on Linux and this PR passes. You are right that on Windowsfile.txt/sub/.stays ENOENT becausestatus()reports not-found there; the description's 'ENOTDIR when the status reports not_a_directory' holds on hosts where it does. I have not run the new test on Linux myself.Imported from boykopovar/AnyPS5. Originally posted by wachi35676 on 2026-10-20T13:13:41Z.
Verdict: confirm, with one small test note. I ran
34acda342on Linux for you.I merged it onto
main44e3389c8(clean merge) and ran on Ubuntu 24.04 (WSL2, as root) with GCC 13.3 and on Windows 11 with WinLibs GCC 15.2.0, both Release.guest_rename_dotpasses, 3 runs out of 3.RenameDot.hppset back tomain, the test fails 3 of 3 atrename from file/. must fail with ENOTDIR (20) (errno 2). I then removed the checks one at a time, and each of the three new Linux checks fails on its own againstmain:rename to file/.gives errno 2.rename from loop/.gives errno 2 instead of ELOOP (62).guest_rename_dotandguest_filesystempass 3 of 3 with and without theRenameDot.hppchange, as you described.Test note:
Cleanup()removes only the three directories. If a run aborts betweensymlinkandunlink,anyps5_rename_dot_loopstays in the test directory (build/core/libs/prx/libkernel). Every later run then fails atcreating the symbolic link loop failed (errno 17), even with the fix. I reproduced this by leaving the link in place before a run of the PR build. RemovingPlainFileandLoopinCleanup()(std::remove/::unlink) would avoid it.AI-assisted: yes (Claude Code); results above were run on this machine.
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-20T20:18:06Z.
Good catch, thanks.
Cleanup()now also removes the plain file and the symbolic link (std::remove; the two names moved to namespace scope), and the test already callsCleanup()before it creates anything, so a leftover link from an aborted run no longer fails the next one with EEXIST (commitfaec856276).guest_rename_dotstill passes on Windows; the loop case runs on Linux only, which I did not run.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T03:40:29Z.
Linux data point for
faec856276(WSL2, Ubuntu 24.04, GCC 13.3, Release,-j4; a virtualised kernel, not bare-metal Linux):guest_rename_dot,guest_filesystemandguest_posix_filesystempass on Linux (3 of 3). This replaces the "Linux not tested" line in the description for this head. Not tested: macOS.AI-assisted (Claude Code).