Skip to content

fix(libkernel): support lstat on long Windows paths - #7202

Merged
oneandonlydean merged 2 commits into
boykopovar:mainfrom
MarcZX10:codex/lstat-long-windows-path-7201
Nov 1, 2026
Merged

oneandonlydean merged 2 commits into
boykopovar:mainfrom
MarcZX10:codex/lstat-long-windows-path-7201

Conversation

@MarcZX10

@MarcZX10 MarcZX10 commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

What

Prepare native Windows stat paths with the extended-length namespace before the lstat metadata calls. Add a Windows filesystem regression that creates a host file under a path longer than MAX_PATH, verifies guest lstat reports the regular file and its size through both ordinary and already-extended host aliases, and verifies missing long paths still report ENOENT.

Tested

Checklist

  • Based on current main; no other open PR implements long-path lstat support
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes (Codex); author responsible.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Thanks, this looks good in review. One note on ordering: we plan to merge #7196 first. After it lands, this PR will need a small rebase. The only conflict is the test in core/libs/tests/GuestFilesystem.cpp; production code merges cleanly. We'll run full CI on the rebased head.

Non-blocking, for a later follow-up if you're interested: with #7187, #7196 and this PR there are now three copies of the \\?\ path-preparation helper. A single shared helper would keep them from drifting.

@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 5021 core/libs/prx/libkernel/File/src/NativeStat.cpp
PR 9371 core/libs/tests/GuestFilesystem.cpp
PR 10319 core/libs/tests/GuestFilesystem.cpp
PR 12560 core/libs/tests/GuestFilesystem.cpp
PR 12820 core/libs/tests/GuestFilesystem.cpp
PR 12835 core/libs/tests/GuestFilesystem.cpp

@MarcZX10

Copy link
Copy Markdown
Contributor Author

Yes, a shared helper is a useful follow-up. These three PRs have separate filesystem call sites, and keeping their current changes focused avoids adding cross-PR conflicts while their fixes are reviewed and rebased. After #7187, #7196 and #7202 land, I can map the common path-normalization rules and propose one internal helper with shared tests, preserving each call site’s existing error behavior.

@MarcZX10

Copy link
Copy Markdown
Contributor Author

Rebased onto current main bd5856170. The GuestFilesystem.cpp conflict came from #6992 adding its long-path stat coverage; I combined the cases so the Windows test now covers both stat and lstat through ordinary and already-extended paths, including missing-path errors. The long-path preparation and symlink-loop errno mapping are separate behaviors; #7111/#7273 change which reparse-point types lstat recognizes, while this change prepares the path used by those lookups. check_conventions.py --base upstream/main, git diff --check, and MinGW C++20 syntax checks of NativeStat.cpp and GuestFilesystem.cpp pass. Full CMake configuration could not run in this worktree because its SDL2 submodule is absent; no hosted checks have reported yet on the rebased head.

@MarcZX10

Copy link
Copy Markdown
Contributor Author

CI update for rebased head 946c44103: eligibility, conventions, and report checks have passed. Windows and broader platform build/test jobs are skipped by the repository path filters, so the MinGW syntax checks remain the Windows compile evidence for this update.

@MarcZX10
MarcZX10 force-pushed the codex/lstat-long-windows-path-7201 branch from 946c441 to bbec884 Compare October 17, 2026 23:59
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 18, 2026
@Bonjourcestmatt

Copy link
Copy Markdown
Contributor

Independent Windows run, since the PR description says the Windows runtime regression could not be run on Linux.

Setup: Windows 11 (MinGW64, native), WinLibs GCC 15.2.0 UCRT, origin/main 66e71b6 with this PR head bbec884 merged.

guest_filesystem (3 runs each) Result
main NativeStat.cpp + this PR's test fails every run: "Filesystem check failed at line 289 (guest errno 2, Win32 error 3)", the lstat_nid_postfix check on the path longer than MAX_PATH
this PR (code + test) passes every run
guest_posix_filesystem with this PR passes (3 runs)

So the new regression does fail without the NativeStat.cpp change on Windows and passes with it.

Not checked: the full non-GPU suite, Linux, macOS, and the stat/sceKernelStat paths (covered by other PRs).

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

@MarcZX10

Copy link
Copy Markdown
Contributor Author

Thanks for running the Windows regression independently. Your three repeated runs confirm that the long-path lstat case fails without the change and passes with it, and that guest_posix_filesystem remains green. I have added this platform validation to my review notes.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 18, 2026
@MarcZX10
MarcZX10 force-pushed the codex/lstat-long-windows-path-7201 branch from bbec884 to 6b3486e Compare October 18, 2026 12:15
@MarcZX10

Copy link
Copy Markdown
Contributor Author

Rebased onto current main at 0d078f75d and pushed 6b3486eed. I resolved the NativeStat.cpp conflict by keeping the current symlink and junction handling while passing the prepared extended path to each Windows API call. git diff --check upstream/main...HEAD and python3 tools/check_conventions.py --base upstream/main pass. I could not run the Windows-only path regression locally on this Linux host; the updated PR checks are pending.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 18, 2026
@MarcZX10
MarcZX10 force-pushed the codex/lstat-long-windows-path-7201 branch from 6b3486e to d815a19 Compare October 18, 2026 12:44
@MarcZX10

Copy link
Copy Markdown
Contributor Author

Rebased #7202 onto current main after #7196 merged; the branch now includes the additional long-path lstat changes and tests from NativeStat.cpp / GuestFilesystem.cpp. The updated commits retain MarcZX100 as author. git diff --check passes, and the local Linux configure/build completed. This checkout exposes no guest_filesystem target on Linux, so I could not rerun the Windows-only regression here. The independent Windows run above passed guest_filesystem 3/3 and guest_posix_filesystem 3/3 on the prior implementation; hosted checks are running for this rebased head.

@MarcZX10

Copy link
Copy Markdown
Contributor Author

Hosted checks for rebased head d815a192: eligibility, conventions, and report all pass. The Linux and Windows build jobs were skipped by path filtering for this Windows-only change. The independent Windows run above remains the runtime validation: guest_filesystem and guest_posix_filesystem each passed 3/3 after the implementation change.

@adriadam10 adriadam10 self-assigned this Oct 19, 2026
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 19, 2026
@adriadam10
adriadam10 force-pushed the codex/lstat-long-windows-path-7201 branch from d815a19 to b4de62c Compare October 19, 2026 13:20
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Oct 19, 2026
@adriadam10
adriadam10 force-pushed the codex/lstat-long-windows-path-7201 branch from b4de62c to ad3dfd1 Compare October 20, 2026 08:54
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 20, 2026
@ycbuzi

ycbuzi commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

A heads-up from the #8534 side, since the overlap bot pairs the two: #8534 adds IsNameSurrogate(p, "lstat") to DoLstat, and when the two are merged git keeps that line on the raw path without a conflict marker. With this PR's long-path preparation everywhere else, a reparse point beyond MAX_PATH then throws std::system_error from that call (lstat: CreateFileW: The system cannot find the path specified). The fix is to pass prepared there and to Read/ReadJunction, which is what I measured passing on Windows (main 4036fab + this PR + #8534: guest_filesystem, guest_kernel_sys, guest_posix_filesystem, plus a long-path name-surrogate case in your long-path block). If this one lands first I'll do that rebase on #8534; if #8534 lands first, the same one-line change applies here. Details on #8534.

@MarcZX10

Copy link
Copy Markdown
Contributor Author

Thanks, that composition issue is real. After #8534's IsNameSurrogate check is combined with #7202, it must receive the prepared extended path, and the subsequent Read/ReadJunction calls need that same path as well. I have not changed #7202 yet because IsNameSurrogate is introduced by #8534 and is not on this PR's base. If #8534 lands first, I will rebase #7202 and update all three calls with the prepared path; if #7202 lands first, please carry the preparation into #8534's DoLstat. The long-path name-surrogate case you measured is the right regression to keep in the combined change.

@MarcZX10
MarcZX10 force-pushed the codex/lstat-long-windows-path-7201 branch from 5d40700 to 665e4cf Compare October 25, 2026 04:57
@oneandonlydean oneandonlydean self-assigned this Oct 30, 2026
@oneandonlydean
oneandonlydean merged commit 9f6d3b9 into boykopovar:main Nov 1, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants