fix(libkernel): preserve DOS device names and trailing dots or spaces on Windows #12560
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12560"
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 Kikoarl on 2026-10-28T20:17:27Z.
What
On Windows hosts, Win32 path canonicalization rewrites file paths shorter than
MAX_PATHwhose components end in a dot (.) or a space (), or whose stem matches a DOS device name (NUL,CON,PRN,AUX,COM1-9,COM¹-³,LPT1-9,LPT¹-³,CONIN$,CONOUT$with or without an extension). This silently redirects guest file operations to host character devices (e.g.nuldropping data) or strips trailing dots and spaces (e.g.file.collapsing tofile), causing guest filesystem corruption orENOENT.This PR introduces
WindowsVerbatimPath.hppand extendsNativeVerbatimPath_nid_no_patch:COM¹-³andLPT¹-³) and path components ending with a dot or space.\\?\for drive paths,\\?\UNC\for network shares) whenever such components are present, bypassing Win32 canonicalization regardless of path length.\\?\or\\.\and normalizes/to\.WindowsMaxDirectoryPathLength = 248(MAX_PATH - 12) for Win32 directory operations (CreateDirectoryW,RemoveDirectoryW), prefixing\\?\when directory paths reach 248+ characters to eliminate Win32 directory creation failures in the [248, 259] range.OpenNative,sceKernelUnlink,opendir,rename, andfopento route paths throughNativeVerbatimPath_nid_no_patch.core/libs/tests/GuestFilesystem.cppverifying both path formatting logic and Windows filesystem syscall behavior, omitting assumptions aboutcom0/lpt0reserved device mapping (Rule L44).Fixes #12550
Tested
guest_filesystem): addedTestWindowsVerbatimPathtesting DOS device stems (NUL,CON,AUX,PRN,COM1-9,COM¹-³,LPT1-9,LPT¹-³), console devices (CONIN$,CONOUT$), trailing dots/spaces, forward slash normalization, idempotency, non-DOS stems, and length thresholds 247/248/259/260.ctest --test-dir /tmp/anyps5_build -R "libc|guest_file|filesystem").CreateFileW,_wstat64, andDeleteFileWonfile.,nul, andconin$.txtpassing all Win32 assertions.python3 tools/check_conventions.pypassed with 0 errors.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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T20:25:48Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The Windows path helper misses the superscript-digit COM and LPT device aliases, so those valid reserved names bypass the new verbatim-path handling.
What I ran
PR head:
476f65332d09398311207a8fdf0a57d2a63962bf; base:319621ba2e578bd053b0baba2877fe70520e0737.Linux x86_64, GCC 12.2.0; this exercised the platform-independent path-name helper, not Win32 file I/O.
git diff --check 319621ba2e578bd053b0baba2877fe70520e0737...refs/review/pr-12560-current— passed.git merge-tree --write-tree 319621ba2e578bd053b0baba2877fe70520e0737 refs/review/pr-12560-current— clean, tree4f03c607285648e9b093972dc1b8374fbc438fdd.git show 476f65332d09398311207a8fdf0a57d2a63962bf:core/libs/prx/libc/include/WindowsVerbatimPath.hpp > /tmp/WindowsVerbatimPath.hppThe probe source
/tmp/test-verbatim-superscript.cppwas:g++ -std=c++20 -I /tmp /tmp/test-verbatim-superscript.cpp -o /tmp/test-verbatim-superscript && LC_ALL=C.UTF-8 /tmp/test-verbatim-superscriptResults
Probe output
Negative control
No source mutation was run. The probe compared the documented ASCII and superscript aliases directly; the ASCII cases are detected and prefixed, while the superscript cases are not.
Findings
Blocking
IsDosDeviceStem_nid_no_patchaccepts only ASCII'1'–'9'forCOM#/LPT#. Windows also reservesCOM¹,COM²,COM³,LPT¹,LPT², andLPT³, including names followed by extensions. A short path such asCOM¹.txttherefore returns false fromPathNeedsVerbatimPrefix_nid_no_patchand receives no\\?\prefix. Please recognize U+00B9/U+00B2/U+00B3 afterCOM/LPTand add narrow/wide tests that verify the detector and final formatted path. The current ASCII boundary cases such asCOM0andCOM10should remain unreserved.Non-blocking
The merge preview is clean and the local diff check passes. The hosted Windows build and runtime behavior were not complete when I checked; the helper probe alone does not verify Win32 I/O.
Sources
Not verified
I did not run Windows/macOS builds, a full project build, or Win32 filesystem tests. I did not verify the added behavior on NTFS/FAT or a console.
To get this to a good state
Recognize and test the superscript aliases above, then I can rerun the helper probe and review the updated Windows checks on the new head.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T20:33:09Z.
Review: CHANGES_REQUESTED
Re-checked — new head, changes still requested
The Windows path change remains incomplete across guest filesystem operations, and this head also omits documented device aliases and removes an unrelated debt entry.
What I ran
Reviewed exact head
476f65332d09398311207a8fdf0a57d2a63962bfagainst base319621ba2e578bd053b0baba2877fe70520e0737.git diff --check 319621ba2e578bd053b0baba2877fe70520e0737...refs/review/pr-12560-current— passed.git merge-tree --write-tree 319621ba2e578bd053b0baba2877fe70520e0737 refs/review/pr-12560-current— clean, tree4f03c607285648e9b093972dc1b8374fbc438fdd.Extracted the PR header and compiled a C++20 probe with GCC 12.2.0 on Linux:
The probe passed ASCII
COM1.txtandLPT3.logthrough the prefix logic, but did not do so for UnicodeCOM¹.txtandLPT³.log.Results
strtoqdebt entryguest_filesystemruntime testProbe output
Negative control
I did not run source mutations or the Windows filesystem test binary. The helper probe directly compared ASCII names with U+00B9/U+00B3 names; the latter bypass the detection that triggers prefixing.
Findings
Blocking
NativeVerbatimPath_nid_no_patch, butNativeMkdirandNativeRmdirstill pass the original path to_wmkdir/_wrmdir; libc remove still passes the originalresolvedpath toGetFileAttributesW,SetFileAttributesW,RemoveDirectoryW/DeleteFileW; and rename's preflight checks use the original source and destination. InRenameNative_nid_no_patch, the verbatim conversion is only used whenreplacesExistingis true; the new-destination branch callsstd::filesystem::rename(source, destination)unchanged. Thus operations on the same guest name can target different host names or still reach a device. Please use one consistently resolved host path for metadata checks and the final operation, and add Windows live regressions for mkdir/rmdir/remove/rename on trailing-dot and device-stem paths, including afile/file.sibling control.IsDosDeviceStem_nid_no_patchonly accepts ASCII digits forCOM#/LPT#. Microsoft's pinned naming reference also reservesCOM¹–COM³andLPT¹–LPT³, with or without extensions. Please recognize U+00B9, U+00B2, and U+00B3 and test narrow/wide detection plus final path formatting.strtoqentry indocs/dev/debt/libc.md. Please restore that entry and add the Windows path note as a separate bullet.guest_filesystem; the reported Wine probe is not the same as running the integrated test on Windows. Please attach theguest_filesystemCTest output from the revised Windows head so the live API behavior in the new test is exercised.Non-blocking
The merge preview with current main and whitespace check are clean. The current PR's macOS hosted jobs were queued at last refresh; macOS is not the target platform for this change.
Sources
strtoqentry in the baseNot verified
I did not run Win32 filesystem operations, the PR's CTest suite, a Windows native build, or console behavior. I did not independently test alternate data streams; the PR's own debt note leaves colon handling out of scope.
To get this to a good state
Make the path representation consistent for every affected filesystem operation, retain the existing
strtoqdebt entry, cover the superscript aliases, and runguest_filesystemon native Windows. I can rerun the helper probe and inspect the resulting exact-head diff and test evidence.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T21:04:45Z.
Review: CHANGES_REQUESTED
Findings
Blocking: the Windows regression test does not compile on the reviewed head
An independent native Windows run of head
476f65332dreports thatGuestFilesystem.cppfails to compile under_WIN32:SCE_KERNEL_O_RDWRandSCE_KERNEL_O_CREATare undeclared. The required declarations are inprx/libkernel/File/include/FileFlags.hpp, which this test does not include. The hosted Windows workflow passed, but its Windows job only linked changed host-only test executables; it did not compile or runguest_filesystem, so it did not catch this failure. Please include the defining header and make sure the Windows test is actually built and run.Blocking: path operations use inconsistent forms
The new verbatim form is not applied consistently across guest-path operations. In particular,
sceKernelMkdirstill passes its resolved path tostd::filesystem::create_directory, whilesceKernelOpenuses the verbatim form. A native Windows reproduction reported thatmkdir("d.")followed byopen("d./save", O_CREAT)now fails withENOENTon this head, while it succeeded on base (though base created the wrongly normalizedd).sceKernelRmdir, rename paths and other libc/libkernel path operations also remain on the plain form. Please route all affected guest-path operations through a consistent representation and add live Windows coverage for mkdir/open, rmdir, rename and same-name siblings such asfileandfile..Blocking: an unrelated debt entry was removed
The current debt diff replaces the existing
strtoqentry with the new Windows path note. Please restorestrtoqas its own entry and preserve the existing “Guest file names on Windows” debt while narrowing it to the characters and cases that remain unsupported. The verbatim-path entry should state the remaining gap rather than replace unrelated documentation.Checks and limits
git diff --check upstream/main...refs/review/pr-12560-currentpassed.guest_filesystem. Linux product tests were skipped.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T23:52:12Z.
Review: CHANGES_REQUESTED
Re-checked — changes requested for native Windows runtime evidence
The current head addresses the reported path consistency, superscript device-name, Windows test compilation, and debt-documentation issues; the remaining blocking gap is execution of the live regression test on Windows.
What I ran
4309769ffc02c6f3139de61a8db0b1177aded163against current base3a2b91981651569163768854a1fcdc7193b6667b.git diff --check upstream/main...upstream/pr-12560— passed.python3 tools/check_conventions.py --base upstream/main --head upstream/pr-12560— passed.WindowsVerbatimPath.hpp; narrow UTF-8 and wide superscript COM/LPT cases and trailing-dot/space formatting passed.x86_64-w64-mingw32-g++ -std=c++20; compilation passed. This checks the platform-independent helper and Windows compiler compatibility, not Win32 filesystem behavior.guest_filesystemexecutable or the new live Win32 filesystem cases.Results
guest_filesystemCTestFindings
The latest diff now routes the reported mkdir/rmdir/rename and libc path operations through the verbatim path helper, recognizes the documented superscript device aliases, restores the unrelated
strtoqdebt record, and adds the missing Windows test header. I found no remaining source-level blocker in those reviewed findings.The PR adds
TestWindowsVerbatimPathLive, which exercises native create/open/remove behavior. The new-head report says it cross-compiles with MinGW but does not provide a native Windows run. Since the Windows behavior is the core of this change and earlier review reports identified Windows-only test compilation gaps, compilation alone does not verify that the live operations work.Sources
Not verified
I did not run native Win32 filesystem operations,
ctest -R '^guest_filesystem$', a full Windows build, macOS tests, or console behavior. The temporary helper probe is not a substitute for the integration test.To get this to a good state
Please run
ctest --test-dir <Windows build> -R '^guest_filesystem$' --output-on-failureon the exact head and attach the output. I can then re-check the live cases and update this review.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T01:44:42Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The new native Windows run confirms that
sceKernelRmdirfails on an empty directory ending in a dot, so the verbatim-path change still cannot remove a path it now preserves.What I ran
Reviewed exact head
4309769ffc02c6f3139de61a8db0b1177aded163against base319621ba2e578bd053b0baba2877fe70520e0737; the current-main merge preview is clean (treedbb9aefb11189d4288eae0915f16802c416bf20e). Environment: Debian GNU/Linux x86_64, Python 3.11.2. I inspected the changedsceKernelRmdirpath and the author-supplied Windows 10 test report.Results
dbb9aefb11189d4288eae0915f16802c416bf20eguest_filesystemsceKernelRmdir("/verbatim-test/d."); see linked exact-head reportRaw local output
git diff --checkproduced no output and exited successfully.Author-reported Windows test output
The author reports this is the
sceKernelRmdir("/verbatim-test/d.")assertion after creating and emptyingd.. A standalone probe on the same Windows 10 system reportsstd::filesystem::is_emptyreturns false with error 2 for the verbatim path, whileFindFirstFileW(path + L"\\*")succeeds.Negative control
sceKernelRmdirFindings
Blocking
sceKernelRmdirtreats every false result fromstd::filesystem::is_empty(targetNative, error)asENOTEMPTYand does not inspecterror(Stdio.cppat this head). On the reported Windows 10 / libstdc++ setup,is_emptycannot enumerate the verbatim pathd., so the implementation rejects an empty directory and the new live test fails. Please use an emptiness check that supports the verbatim Windows path (or otherwise handle this filesystem error correctly), then remove the directory and rerun the exact Windows test. The native failure report is here.Non-blocking
Sources
4309769ffc02c6f3139de61a8db0b1177aded163sceKernelRmdirat the reviewed headNot verified
I did not run native Windows filesystem tests, the full
guest_filesystemtest binary, macOS tests, or PS5 hardware/title behavior. The native Windows failure is from the author's exact-head report, not a run on this Linux host.To get this to a good state
Fix the Windows emptiness check for verbatim paths and rerun
ctest --test-dir <Windows build> -R '^guest_filesystem$' --output-on-failureon the updated head; I will re-run the local checks above and review the new native output.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T08:37:55Z.
Review: CHANGES_REQUESTED
Re-reviewed exact head
4309769ffc02c6f3139de61a8db0b1177aded163after the new Windows run. The author-runguest_filesystemtest fails 3/3 on this head while the same test passes 3/3 onmain; the failure is the newsceKernelRmdir("/verbatim-test/d.")case (Win32 error 3). The preceding mkdir, file creation/stat/unlink and sibling-name checks pass, so the trailing-dot directory is created and used but cannot be removed. Please fix the completesceKernelRmdirpath handling for that name and rerunguest_filesystemon Windows, retaining the regression. This is a blocking runtime failure; the hosted Windows job does not run this guest test. I did not run Windows tests locally.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-30T08:28:29Z.
Review: CHANGES_REQUESTED
Re-checked — changes requested
The current branch conflicts with upstream
main; the new path-length report is also not evidence that the earliersceKernelRmdirfailure is fixed on this head.What I ran
Reviewed PR head
42d1ec15867f5faa2c9fad45ca0850f5122cf06c; its PR base isbb04a4f1ea0175e9e4f149f0359a764d62ff3296. I compared it with currentmainat98ddd9c1792bbab016ceed5db267a93d1d61f00a. Environment: Debian 12, Linux x86_64, Python 3.11.2, Git 2.39.5. No compiler or project build was run.Results
core/libs/prx/libkernel/CMakeLists.txt:347registersGuestFilesystem.cppasguest_filesystem_testscore/libs/prx/libc/src/Rename.cppandcore/libs/prx/libkernel/File/src/Open.cppsceKernelMkdir, not the priorsceKernelRmdircaseRaw command output
git diff --checkproduced no output and exited successfully.The precheck's isolated worktree did not contain the local-only audit helper scripts; I ran the ABI and test-quality helpers directly against the exact PR checkout. Their raw outputs were JSON; the ABI audit reported
"status": "passed"and"findings": []. The test heuristic's registration warning is shown above and was checked against CMake.Negative control
Not run. The Windows filesystem assertion requires the native Windows test environment; I did not alter the code under test.
Findings
Blocking
Rename.cppandOpen.cpp. Please update the branch and resolve those conflicts before merge.Non-blocking
mainstill passes an unprefixed path tostd::filesystem::create_directoryinsceKernelMkdir(source at current main). The new report does not test the earliersceKernelRmdir(".../d.")failure on this PR head.Sources
42d1ec15867f5faa2c9fad45ca0850f5122cf06csceKernelMkdirNot verified
I did not build the project or run
guest_filesystemon Windows. The earlier native Windows failure report is for head4309769ffc02c6f3139de61a8db0b1177aded163, not this head. No console or macOS behavior was tested.To get this to a good state
Please resolve the two current-main conflicts and run
ctest --test-dir <Windows build> -R '^guest_filesystem$' --output-on-failureon the updated head, including the trailing-dotsceKernelRmdircase. I will rerun the same relevant checks on the new head.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-30T11:29:58Z.
Review: APPROVED
Re-checked — new head, looks good
The updated head adds live Windows regression coverage for the previously failing trailing-dot directory removal and long directory-path cases, and the hosted Windows test job passed; I approve this revision.
What I ran
Reviewed head
718027132c6aadb27f792e552327c05f77540072against basee049725553c4cf9770eb06d2ab1a211059efd29don Linux x86_64 (Debian 12, Python 3.11.2, GCC 12.2.0). The local precheck ran diff and convention checks; I inspected the exact-head Windows test changes and current GitHub check results. I did not build locally.Results
guest_filesystemCTest targetwrite-watchObserved command output
Negative control
Findings
Blocking
None found in the reviewed revision.
Non-blocking
The macOS
write-watchjob failed at its standalone CMake configure step. The run is still in progress, so its diagnostic log is not available; this PR does not modify that test project's files. The remaining queued macOS jobs were not complete at review time.Sources
Not verified
No local build or C++ tests; no console or GPU behavior; remaining queued macOS checks; exact cause of the macOS
write-watchconfigure failure.