fix(libc): change into a directory reached through a substituted drive on Windows #24149
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/24149"
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 XFlawless1 on 2026-11-20T08:01:34Z.
What
Depends on #24114: this branch contains its commit. Only the last commit (
fix(libc): change into a directory reached through a substituted drive on Windows) belongs to this PR; I will rebase once #24114 is merged.On Windows,
fchdirinto a directory fails with error 45 when the emulator was started from a substituted drive (subst,DefineDosDevice), even for a short path.fchdirgets the directory's final path from its descriptor, which names the drive's target (C:\...), while the root keeps the letter it was started from (W:\...).SetWorkingDirectoryrelates the two by walking up withstd::filesystem::equivalent, which MinGW's libstdc++ decides by drive letter, so no ancestor ever matched.SetWorkingDirectorynow compares the final paths of the directory and of the root first (FinalDirectoryPath, added in #24114) and uses that relation; theequivalentwalk stays for anything they do not relate.guest_kernel_sys_substituted_drive(Windows, new executable) maps a free drive letter to a temporary directory withDefineDosDeviceW, starts there, opens a subdirectory, and checksfchdirandgetcwd. It removes the mapping and the directory on every exit, including a failed check, and returns 77 (skipped) when no letter can be mapped. It is a separate executable because the root is taken from the working directory at the first libc path call.Tested
Windows 11, MinGW-w64 GCC (WinLibs UCRT), Ninja, Release, AMD Ryzen 7 9800X3D. Found with the build directory on a
substdrive: with #24114 and #24130 applied,guest_kernel_sysstopped at itsfchdir(directory)check with errno 45.General.cppfrom #24114, the new test fails atfchdirwith errno 45 and leaves no drive mapping or directory behind. With the change it passes, three runs in a row, also inside the parallel full run.ctest -j16(6471 tests) against the #24114 run: the only differences areagc_driver_store_over_untracked(#22670) andagc_driver, which flip between runs under the parallel load.tools/check_conventions.py --base origin/mainpasses.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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-20T08:04:46Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
7a254b3875:tools/check_conventions.pypassed.guest_kernel_sys_tests,guest_working_directory_testsbuilt cleanly.guest_kernel_sys,guest_working_directory):core/libs/prx/libc/src/General.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T08:30:01Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the inspected code supports the described Windows directory handling and adds targeted regression coverage.
What I ran
Reviewed head
7a254b387596c4eb1ae083ac100da7bc7c8b07c6usingrepo_read.pyto inspect the prepared description, commits, manifest, diff, and changed file contents. No build or tests were run in this review.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Build/test results reported in the PR description were not independently run. Read all five changed files listed in the manifest;
files.jsonwas not available in the prepared review interface. No changed files were excluded from this review.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T04:10:22Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the points below are optional.
What I ran
Reviewed head
37af04807707a8c6456a7d4be5e468f8f3a3c24fusing the pinnedrepo_read.pyreader. No build or tests were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No programmatic checks were run. The author’s Windows test results were not independently verified. Read
description.md,commits.md,manifest.json, anddiff.patch; read all five changed files listed in the manifest. No files were excluded from review.To get this to a good state
Nothing is required.