fix(libc): report ENOTEMPTY when a host rename onto a non-empty directory fails with EEXIST #27771
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/27771"
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 shinhop on 2026-11-27T09:20:20Z.
What
On Linux,
rename(2)onto a non-empty directory may fail with eitherENOTEMPTYorEEXIST; XFS returnsEEXIST.RenameNative_nid_no_patch(libcrename) andRenamePath(libkernel_sysrenameat) passed the host error through, so on XFS the guest sawEEXIST(17) where the console reportsENOTEMPTY(66). Both now translate a hostEEXISTfromrenametoENOTEMPTYoutside Windows. The Windows paths are unchanged: they already check the destination withis_emptybefore renaming.A pre-rename
is_emptycheck on Linux is not used because it needs read access to the destination: renaming onto an empty directory with no permissions succeeds natively and is checked byguest_kernel_sys.Tested
Fedora 45 (glibc 2.44), Ryzen 9 3900X, build and tests on XFS, this branch is based on
main0156867329.main21e1e006c3:guest_kernel_sys(GuestKernelSys.cpp:2285),guest_filesystem(GuestFilesystem.cpp:1292) andguest_kernel_rename(GuestKernelRename.cpp:142), the checks that rename a directory onto a non-empty directory, fail 10/10 with guest errno 17 when the working directory is on XFS, and pass with the working directory on tmpfs.ctest --test-dir build -j 8, 7119/7119 passed; the three tests above passed 10/10 each withctest -R "^<test>$" -j 1.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T09:40:53Z.
Review: APPROVED
Reviewed — looks good
The change maps host
EEXISTfrom non-Windows rename operations to guestENOTEMPTYin both affected paths; the reviewed code supports merging.What I ran
Reviewed head
96b7e87c1a1edaf0145e8106af26e3229dbb05b. No commands or tests were run; the author reports Fedora 45/XFS test results in the PR description.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Tests and runtime behavior were not independently verified. Read
description.md,commits.md,manifest.json,diff.patch,core/libs/prx/libc/src/Rename.cpp,core/libs/prx/libkernel_sys/Export.cpp, andcore/libs/prx/libc/src/HostErrno.cpp. All changed files markedreviewedin the manifest were read.files.jsonwas not available in the prepared review folder, so excluded-file status was not verified.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-11-28T05:06:21Z.
Review: APPROVED
Checked head
96b7e87c1a. All on Windows 11 with WinLibs GCC 15.2 (Release), applied tomaina163d4b886together with #27930, #27929, #27926, #27925, #27924, #27923, #27922, #27901, #27828, #27755, #27748, #27682, #27765.tools/check_conventions.py --headandtools/debt_fold.py --checkpassed and the full build succeeded. Both changes are compiled out on Windows: the first is in the non-Windows#elseofRenameNative_nid_no_patch, the second is under#ifndef _WIN32inRenamePath. So here I could only confirm that the build works and thatguest_kernel_renameandguest_rename_dotstill pass. The mapping matches POSIX, which allows eitherEEXISTorENOTEMPTYwhen the target is a non-empty directory. In the full CPU suite (5,120 tests) the only failures are unrelated:windows_read_trap_unknownfails onmaintoo (fixed in #28028).frame_capture_minimize,jpeg_external_toolchainandguest_pthread_mutex_contentionare timeouts under load; they pass when run on their own.guest_audio_in_capturepasses 20/20 onmainand with #27922.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T09:02:42Z.
Review: COMMENTED
Ran a Linux comparison of
RenameNative_nid_no_patchwith the exact before and after sources. Renaming onto a real nonempty directory returned ENOTEMPTY in both. With a simulated host EEXIST on that operation, the old code returned EEXIST and the new code returned ENOTEMPTY. Injected EACCES passed through in both versions. I checked the parallel guest-kernel mapping in source.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.