feat(libSceNKWebKit): implement the WTF path and directory operations #14949
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14949"
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 w4rc0n on 2026-11-02T03:15:14Z.
What
Six
WTF::FileSystemImplpath and directory functions wereNotImplementedstubs. They now follow the pinned PS5 WebKit 11.x source, and do all their work on guest paths through AnyPS5's existing guest providers, with no host-path bypass:fileExistsfollows symlinks, through gueststat(libkernelFile/src/Stdio.cpp:1131).deleteFileuses guestlstat(:1139) andunlink(:1152) to tell files and symlinks from directories, and refuses directories as the source does.deleteEmptyDirectoryapplies the source's symlink check, then guestrmdir(:1677).makeAllDirectoriescreates each missing parent with gueststatandmkdirat mode 0777 (:1023), handlingENOENTandEEXIST. It splits the path on slashes only, with no host normalization.moveFileisrenameon PlayStation (FileSystemPlayStation.cpp:60-70), through libc's existingRenameGuestPath_nid_no_patch(libc/src/Rename.cpp:137), the helper that libc's guestrenameexport wraps (:180-182). It is called directly because libkernel also compiles that file and keepsrename_nid_postfixunder its plain name while NKWebKit's import of it is patched to the NID. On Windows the import binds to libkernel and the library failed to load with error 127; Linux's global symbol lookup hid that.realPathuses libc's guestrealpath(RealPath.cpp:217), which returns a guest path. On failure it returns the original string (FileSystemPlayStation.cpp:139-144).These functions inherit the providers' current gaps, such as the parts of mutation,
lstatandrealpaththat don't yet handle archives. They don't work around them. Links andfilesHaveSameVolumeare later work.lastComponentOfPathIgnoringTrailingSlashis left to #14858, which implements it.tools/pr_overlap.pyon this head, withmainat0eba5db30d: no other open PR changes these exports or adds the same files. For the PRs it couldn't compare because they no longer merge withmain, GitHub's file lists show none of them changing these exports either. #13947, #13992, #14981, #15011, #15215 and #15498 change nearby lines in the same files; whichever merges later keeps both sides. The only exports it shares are with #14932, in the same stack.Tested
Debian 12, GCC 12.2, Linux 6.18, Release, at the head
10590b54e756b0b48baf1f6d515f365ba22d1530. It is on #14931's head0efdf47930434f6317c4a572ea0af7cf501e0095. The selection was the thirteen NKWebKit tests (nkwebkit_constantsand upstream's newernkwebkit_fastbitvector,nkwebkit_resourceresponse,guest_nkwebkit_urlsandnkwebkit_palsessionidincluded),public_headersandpatched_libraries, and the fulllibstarget was built.patched_libraries.nkwebkit_wtfaborts withguest path: process_vm_readv failed with errno 38once it reaches a guest path. Its lexical checks run before that. This machine's kernel has noprocess_vm_readv; the Linux CI run below reaches it.nkwebkit_wtfcases cover:makeAllDirectories;deleteEmptyDirectoryon non-empty, symlink and missing paths;realPaththrough an alias and on a missing path;set_gidon its temporary root, and checks the new directories' mode withperms::all, since they inheritS_ISGID. XairRrR's review found that the earlierperms::maskcheck failed in a setgid build directory. With the local fallback, the previous head's check aborts under this fixture (the new directories read02777), andperms::allpasses.libSceNKWebKit.prxlistslibkernel.prxas needed, andldd -rreports no undefined symbols.libSceNKWebKit.prximportsRenameGuestPath_nid_no_patchand norenameNID.tools/progress.py: the six exports count as implemented (libSceNKWebKit 1324, against 1318 with #14931).tools/check_conventions.pypasses.d82592c45b330f97325194d1223c930fb41e1ab9. It is AnyPS5'sBuildworkflow, dispatched in the author's fork withselect=true: the branch merged intomainat93dbd0f82aea684e95f15f06e7d42c0064af18cf, built onwindows-latestwith WinLibs GCC 15.2 (MinGW-w64, UCRT). None of the 672 selected tests failed; 6 AGC tests were skipped, whichcheck_skips.pyaccepts. That includes the nine NKWebKit tests,public_headersandpatched_libraries. The first attempt of run 41376713519 timed out two unrelatedcheck_compile_modes_test_clang_*tool tests at 30 s, which pass in 2-3 s in every other run; the failed job was rerun and passed. Since that run, the rebases ontomain(now0eba5db30d8a3d03789e52e5c1a9ff853e4e33e4, after #14479, #15228, #13766, #14925 and #15911) changed onlydocs/dev/debt/libSceNKWebKit.md, and the review fix changed only the directory-mode check and its setgid fixture intests/Wtf.cpp, sogit range-diffshows the production code is the same as at that run. A fork-internal pull request existed only to give the workflow a number.c6239ff3daf17b2ce0b7c9a94bb583a9c4a06939with the fulllibstarget onubuntu-latest(Ubuntu 24.04, kernel 7.0, GCC 13.3). 13 of 13 pass, includingnkwebkit_wtf(with the setgid fixture) andpatched_libraries. The later rebases ontomain(now0eba5db30d8a3d03789e52e5c1a9ff853e4e33e4, after #13766, #14925 and #15911) changed onlydocs/dev/debt/libSceNKWebKit.md, sogit range-diffshows the code and tests under test are the same as at that run.Local fallback used for the second run (not in this PR)
Not built or run: macOS. The permission and symlink cases run on Linux only. No title or homebrew was run.
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 BunnyFl on 2026-11-02T16:54:58Z.
Review: APPROVED
Build and test on Windows (WinLibs GCC,
BUILD_TESTING=ON), PR merged into currentmain:nkwebkit_wtfpasses. With the PR's source file taken frommain, the test executable doesn't link, since the exports are new, so there's nomaincontrol.The six functions go through the existing guest providers (
stat,lstat,unlink,rmdir,mkdir,RenameGuestPath_nid_no_patch, guestrealpath), with no host-path bypass, andrealPathreturns the original string on failure asFileSystemPlayStation.cppdoes. CallingRenameGuestPath_nid_no_patchdirectly, rather than going through the NID-patchedrenameimport, is a sound fix for the Windows load error 127 the PR describes.I didn't compare these against the firmware module. The approval rests on the pinned WebKit source and the passing test.
Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T10:05:51Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The six path and directory functions follow the pinned WebKit source and use the guest providers. The new
nkwebkit_wtftest fails here, though, because a permission check on the directory it creates also compares the setgid bit.What I ran
Head
4726a384e8bd999342f9836aa4a3a5d62b3a4d4a,main4f41f4c375f5abb487dbd184fbc150f31994d762, merged tree21667d859ad63faecd7ea397a386110ca934b307. Debian 13 VM, GCC 14.2.0, Release, Ninja,BUILD_TESTING=ON.Results
git diff --checkcheck_conventions.pylibs(script)nkwebkit_wtfmain's baselinepublic_headers_*,patched_libraries(76 tests)nkwebkit_wtfwith line 508 masked byperms::allunwrap_self_..._inherits_the_destination_directory_groupmain, not caused by this PRFailure, with Require() printing its line (instrumented file, one line below the original)
In the unmodified file this is line 508, the check of the permissions on
root / "a" / "b".Why: the build directory has the setgid bit
Negative control
With
core/libs/prx/libSceNKWebKit/src/WtfSystem.cpptaken frommain,nkwebkit_wtf_testsdoes not link: there are undefined references toWTF::FileSystemImpl::fileExists,deleteFile,deleteEmptyDirectory,realPath,makeAllDirectoriesand the others. The exports are new, so this is the only control possible, as BunnyFl also found on Windows. Afterwards I restored the merged files and rebuilt.git status --porcelainis empty.Findings
Blocking
makeAllDirectoriesmode check fails under a setgid parent directory. It is attests/Wtf.cpp:508.std::filesystem::perms::mask(07777) and expects exactly 0777.S_ISGID. The guestmkdircorrectly gives 02777, so the comparison fails andnkwebkit_wtfaborts with no message. That happens in this review's build tree, and in any shared or group-owned checkout withg+s. The implementation itself behaves correctly.std::filesystem::perms::all(0777), which is what the assertion means to check. With that one change the whole test passes here. The file checks at the otherperms::masksites are unaffected, because regular files don't inherit setgid, and they passed here.Non-blocking
None.
Not verified
FileSystembehaviour:deleteFilerefuses directories vialstat,moveFileisrename, andrealPathreturns the input on failure.openFile,seekFile, and the others). I only exercised those through the shared test. I did not review that commit's semantics beyond the test.To get this to a good state
core/libs/prx/libSceNKWebKit/tests/Wtf.cpp:508, replacestd::filesystem::perms::maskwithstd::filesystem::perms::all, then rerunnkwebkit_wtf.Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T10:55:08Z.
Review: APPROVED
Re-checked — approved
The new head fixes the blocking test failure. In
tests/Wtf.cppthe directory-mode check now masks withperms::all, and the test sets setgid on its own temporary root, so the inherited-S_ISGIDcase runs on every host.What changed since my last review
4726a384toc6239ff3changes onlycore/libs/prx/libSceNKWebKit/tests/Wtf.cpp:std::filesystem::permissions(root, perms::set_gid, perm_options::add)runs on the temporary root (L494-L496).makeAllDirectoriesmode check masks withperms::allinstead ofperms::mask(L511).What I ran
Head
c6239ff3daf17b2ce0b7c9a94bb583a9c4a06939,main4f41f4c375f5abb487dbd184fbc150f31994d762, merged tree9cbbd5dd6538f02f45461442039f97ff6127c700. Debian 13 VM, GCC 14.2.0, Release, Ninja,BUILD_TESTING=ON.git diff --checkcheck_conventions.pylibs(script)mainfailure (unwrap_self_..._inherits_the_destination_directory_group), not caused by this PRpublic_headers_*,patched_libraries(77 tests)2775(setgid), the case that failed last timenkwebkit_wtfwith the oldperms::maskcheck, run from a non-setgid directorynkwebkit_wtfat the head, run from the same directoryPrevious findings
makeAllDirectoriesmode check fails under a setgid parent (tests/Wtf.cpp:508at4726a38): Resolved.perms::all, andnkwebkit_wtfpasses in this review's setgid build tree.perms::maskcheck back makes the test abort even when it runs from a directory without setgid. So the new fixture reproduces the case on any checkout, as the author said in their reply.Negative control
src/WtfSystem.cpptaken frommainthe test does not link. I recorded that in my last review, and the production code has not changed since, so I did not repeat it.git status --porcelainis empty.New findings
None.
Not verified
FileSystemsources.Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-04T15:39:42Z.
Review: APPROVED
@w4rc0n re-checked at
e4db024ffc.git range-diffof my approvedd82592c45bagainst this head shows one change to this PR's own patch, in the test, which is the fix for XairRrR's finding:perms::all(core/libs/prx/libSceNKWebKit/tests/Wtf.cpp:511).:495). An inheritedS_ISGIDthen no longer depends on the checkout's group.The library code is unchanged.
What I ran: head
e4db024ffc(it already containsmainb11c7bf84f), Windows 11, WinLibs GCC, Release,BUILD_TESTING=ON:nkwebkit_wtfandpublic_headers: 2 of 2 pass. On Windows the setgid line is inside#ifndef _WIN32(Wtf.cpp:494-496). This run covers theperms::allcheck only.check_conventions.py --base upstream/mainpasses.pr_overlap.py --branch: 76 open PRs touch the same files. Two share exports:deleteFile,fileExists,truncateFileand others. It is a 695-file branch (git diff --statagainstmain). Whichever of you lands second will need to resolve that.Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-05T03:18:07Z.
Review: APPROVED
@w4rc0n re-checked after the force-push.
10590b54e7is a rebase ofe4db024ffc, the head I approved:git range-diffshows no change to any code or test line. The only differences are hunk context and the dropped edit of the "Additional callable exports" count line indocs/dev/debt/libSceNKWebKit.md, whichmainhas since reworded.On
10590b54e7merged ontomain0540ef0ef2(Windows 11, WinLibs GCC 15.2.0, Release,nkwebkit_wtf_testsrebuilt),nkwebkit_wtfpassed, 1 of 1. The new code is in a file this PR adds (core/libs/prx/libSceNKWebKit/src/WtfSystem.cpp), and there is nomainversion to put back; neither of my earlier reviews had a behavioural negative control; I added one this time. Mutation check, on the same merge: with the newdeleteFileaccepting directories instead of refusing them (!=changed to==on the file-type test),nkwebkit_wtfaborts on aRequire.check_conventions.pypasses.pr_overlap.py --branch: the rows with the same exports are your own #14932 (also stacked on #14931, which this one builds on). The other comparable rows share lines inExport.cpp, the export headers or the debt file but no exports; I haven't checked each of them against this PR. The tool couldn't compare about 50 more PRs, which conflict withmain.Approving again at
10590b54e7.AI-assisted: yes (Claude Code)
Pull request closed