libkernel/libc: rmdir, sceKernelRmdir and remove delete the directory for "dir/." instead of failing with EINVAL; fix branch ready #3116
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 milescoviello on 2026-10-10T22:35:07Z.
Guest paths are normalized lexically (
Resolveinlibc/src/General.cpp), sodir/.reaches the host asdir/and the directory is removed. FreeBSD'skern_rmdiratrejects a final.withEINVAL("No rmdir "." please."), and POSIX requiresrmdirto fail withEINVALwhen the last component is dot.removecallsrmdirfor a directory (FreeBSDlib/libc/stdio/remove.c).On main (Linux), each of these returns 0 and the directory is gone:
rmdir("probe_dir/."),sceKernelRmdir("probe_dir/."),remove("probe_dir/.").Fix on my fork:
milescoviello/AnyPS5:fix/rmdir-dot-component(one commit,9aaf6240, rebased ontomainec77a616after #3395):sceKernelRmdir(and thereforermdir) andremovereturnEINVAL(0x80020016) and keep the directory. A missing path or a file before the dot keeps its current error.guest_filesystemgains checks that fail on main and pass with the fix. Linux only; Windows was not built or tested. The check runs on the guest path before any host call, so the code is portable.Setup: Gentoo, Linux 7.2.8, GCC 15.3.0, Release with CI's configure flags,
main4d27834f.Tested: the new checks fail on
mainand pass with the fix. Fullctestwith the fix on Linux (RTX 5090 Laptop GPU): no new failures; the only failures are the knownagc_driver_dcc_keys_first_write(#2767) and twoguest_video_out_*tests that time out with the displays powered off.tools/check_conventions.pypasses. All five fixes I am filing today also pass their tests merged together on the currentmain.Not opened as a PR because intake is paused for new contributors; a maintainer is welcome to carry the commit.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by Silverash-i8 on 2026-10-11T01:18:43Z.
Windows run, since the issue says it wasn't built or tested there: Windows 11, WinLibs GCC 15.2.0 r7, Release,
fix/rmdir-dot-component(a43ccf41) merged ontomain06da1176together with #3117, #3181 and #3169 (#3169 is needed here becauseguest_filesystemotherwise stops at the symlink checks on a machine without the symlink privilege).RemoveDirectoryWcollapses the dot itself, so a plainrmdirofdir\.removesdir(checked directly with Python'sos.rmdir).guest_filesystemsit outside the non-Windows block and pass:rmdir,sceKernelRmdirandremoveofdir/.anddir/./return EINVAL (0x80020016 forsceKernelRmdir) and the directory stays. The backslash paths the test builds on Windows work sinceFinalPathComponentIsDot_nid_no_patchsplits on both separators.ctest -E "^agc_") pass with the four branches merged.AI-assisted (Claude Code); I ran this on my machine.
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-11T01:21:10Z.
Thanks @Silverash-i8 for the Windows runs on this and #3117, and for checking
RemoveDirectoryWdirectly. Good to know the dot case is fixed on Windows too. The\\?\idea for..on Windows is useful as well.Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-11T09:58:44Z.
Rebased onto
mainec77a616: #3395 changed the same lines ofsceKernelRmdir. The dot check now runs right after its ENOTDIR/ENOENT block, which keeps FreeBSD's order (lookup errors first, then EINVAL, then ENOTEMPTY). New commit9aaf6240. The 33 file, path and save-data tests pass, including #3395's new checks, andguest_filesystemfails with the check reverted.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by Silverash-i8 on 2026-10-11T10:09:38Z.
Windows recheck of the rebased
9aaf6240onmainec77a616(Windows 11, WinLibs GCC 15.2.0 r7, Release):guest_filesystempasses, now all the way through since #3169 is in, and the non-GPU suite (ctest -E "^agc_") is 453/454. The one failure iswindows_exceptions, which fails the same way on plainmain(#3411), so nothing from this branch.AI-assisted (Claude Code); I ran this on my machine.