feat(libSceNKWebKit): implement WTF FileSystemImpl hardLinkOrCopyFile #25541
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/25541"
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 pinewhite on 2026-11-22T08:06:56Z.
What
Implement
WTF::FileSystemImpl::hardLinkOrCopyFilein libSceNKWebKit so the export no longer reachesNotImplemented_nid_no_patch.The body follows the pinned FileSystem.cpp:730–742: it first tries the existing guest libkernel_sys
linkexport, and when linking fails it copies the target into the link path. The destination is created exclusively, so an existing link path is never overwritten and the call returns false; a missing target also returns false. The copy keeps the target's permission bits, uses the existingopenFile/closeFileand guestread/write, and removes a partially written link path.libSceNKWebKitnow linkslibkernel_sys, which provideslink, andtests/WtfFileSystemLinks.cppcovers hard links inside one and across two directories, the cross-device copy fallback (source permissions preserved, different files), the missing-target and existing-link-path failures, an empty file and null paths.The other link helpers next to it (
hardLink,createSymbolicLink,appendFileContentsToFileHandle) stay stubs on purpose: open PR #19823 already implements them, so this PR does not duplicate that work.Tested
Linux aarch64 (Ubuntu 24.04, GCC 13.3.0), host filesystem,
mkdtempunderTMPDIR.g++ -std=c++20 -O1 -ffunction-sections -fdata-sections -Icore/libs -c, linked with-Wl,--gc-sections) of the realsrc/WtfFileSystem.cpp,src/WtfString.cpp,src/WtfSystem.cpp,src/Bmalloc.cppandtests/WtfFileSystemLinks.cpp, with only the guest libc/libkernel seam shimmed over host POSIX:stat,lstat,open,close,read,write,link,unlink,fchmod,__error,AddPathAliasandApplicationHeapRegister.FileStat.st_birthtimis filled the way the tree's Linux stat does.exit 0), including the cross-device copy fallback (/dev/shmversusTMPDIR).src/WtfFileSystem.cppplus the baseExport.cppstub body, the same test stops at the first call:fatal error: _ZN3WTF14FileSystemImpl18hardLinkOrCopyFileERKNS_6StringES3_ not implemented(exit 134).tools/progress.py --module libSceNKWebKit: 3915 -> 3916 done of 11252, identical to--rooton the pristine baseline and tomainat8c815346d7.python3 tools/check_conventions.py --base origin/main,python3 tools/debt_fold.py --checkandgit diff --checkpass. The full CMake test target was not built locally: the ICU, QuickJS, Cairo and JSC submodules are not initialised in this checkout.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 repositoryImported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-22T08:16:51Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
7b597d6568:tools/check_conventions.pypassed.nkwebkit_wtffilesystemlinks_testsbuilt cleanly.nkwebkit_wtffilesystemlinks):core/libs/prx/libSceNKWebKit/Export.cpp,core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp,core/libs/prx/libSceNKWebKit/include/WtfExports.hpp,core/libs/prx/libSceNKWebKit/src/WtfFileSystem.cppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T08:21:44Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: make the copy loop fail when a write returns zero bytes for a nonempty buffer, so it cannot spin indefinitely.
What I ran
Reviewed head
7b597d65687e7c2dc3697480b175f6e443edb919. No commands or tests were run during this review; I inspected the prepared diff and targeted source ranges usingrepo_read.py.Results
Findings
Blocking
core/libs/prx/libSceNKWebKit/src/WtfFileSystem.cpp:115:WriteToFileaddsbytesWrittentooffsetwithout handling a zero-byte write. For a nonempty chunk, a zero return leavesoffsetunchanged, causing the cross-device fallback to loop forever. Treat zero as failure (and let the existing cleanup path remove the partial destination).Non-blocking
None.
Not verified
No tests or builds were run in this review. The author-reported host POSIX harness and convention checks were not independently rerun. The full CMake target and physical-console behavior were not verified. Read:
core/libs/prx/libSceNKWebKit/CMakeLists.txt,core/libs/prx/libSceNKWebKit/Export.cpp(targeted range),core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp(targeted range),core/libs/prx/libSceNKWebKit/include/WtfExports.hpp,core/libs/prx/libSceNKWebKit/src/WtfFileSystem.cpp,core/libs/prx/libSceNKWebKit/tests/WtfFileSystemLinks.cpp,core/libs/prx/libc/include/GuestErrno.hpp,core/libs/prx/libc/include/GuestFilesystemPrimitives.hpp,core/libs/prx/libkernel/include/Api.hpp(targeted range),core/libs/prx/libkernel_sys/include/Api.hpp(targeted range), anddocs/dev/debt/changes/wtf-filesystem-hard-link-or-copy.md. The manifest lists all six changed files as reviewed; the two files excluded from the review folder due to size,Export.cppandInventoryExports.hpp, were read through targeted ranges from the pinned head.To get this to a good state
Handle a zero-byte write as a copy failure, then rerun the relevant test and full CMake target when dependencies are available.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-22T08:41:42Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
51f8d2ec53:tools/check_conventions.pypassed.nkwebkit_wtffilesystemlinks_testsbuilt cleanly.nkwebkit_wtffilesystemlinks):core/libs/prx/libSceNKWebKit/Export.cpp,core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp,core/libs/prx/libSceNKWebKit/include/WtfExports.hpp,core/libs/prx/libSceNKWebKit/src/WtfFileSystem.cppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T09:03:14Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the focused implementation and wiring review found no verified defect.
What I ran
Reviewed head
51f8d2ec53f8ad466a04bde2e80815d0a1bc9a08usingrepo_read.pyto inspect the prepared diff and targeted source ranges. No build or tests were run; the test results in the PR description are author-reported.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Export.cppandinclude/InventoryExports.hppwere excluded from the prepared full-text bundle because they exceed its size limit; I read only the relevantExport.cpprange andInventoryExports.hppdeclaration range through the pinned reader. No other repository files were read beyond the targeted ranges. No build, test, console behavior, or independent confirmation of author-reported checks was performed. The changed files read werecore/libs/prx/libSceNKWebKit/CMakeLists.txt,core/libs/prx/libSceNKWebKit/Export.cpp,core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp,core/libs/prx/libSceNKWebKit/include/WtfExports.hpp,core/libs/prx/libSceNKWebKit/src/WtfFileSystem.cpp,core/libs/prx/libSceNKWebKit/tests/WtfFileSystemLinks.cpp, anddocs/dev/debt/changes/wtf-filesystem-hard-link-or-copy.md. The manifest lists seven changed files; all were read at least in the relevant ranges.files.jsonwas not available through the reader.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T14:09:53Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: failed hard-link attempts must not fall through to copying for failures other than cross-device links.
What I ran
44b2e700228db95701613196b664163037385495; base ismain. No merged-preview check or commands were run.CMakeLists.txt,WtfExports.hpp,WtfFileSystem.cpp, the new test, and the debt note. Read targeted ranges fromExport.cppthroughrepo_read.py.Results
Findings
Blocking
core/libs/prx/libSceNKWebKit/src/WtfFileSystem.cpp:196: everylink()error triggers a copy attempt. This includes errors such as permission denied, invalid source type, or a missing source, where the API should return false; it can also create a destination copy despite the hard-link operation failing for a reason unrelated to crossing filesystems. Restrict the fallback to the cross-device error (EXDEV), and return false for other link errors.Non-blocking
None.
Not verified
Export.cppandInventoryExports.hppwas excluded from the prepared folder; only targeted ranges were read.files.jsonwas not available under the reader's review paths, so the excluded-file list could not be independently checked.To get this to a good state
Imported from boykopovar/AnyPS5. Originally posted by throny on 2026-11-22T16:41:08Z.
Review: APPROVED
Review: ✅ correct, I'd merge it
Basis: code read against PS5-WebKit-11.x
80f77e94c6WTF/wtf/FileSystem.cpp:730-742Checked
hardLinkOrCopyFiletriescreate_hard_link, falls back tocopy_fileon any error, and returns!ec.copy_filefails when the destination exists and copies permissions. The PR does the same through guest exports:link_nid_postfixresolves both paths through the VFS, the copy usesopenFilewithO_CREAT|O_EXCLplusread/write, thenfchmod. EXDEV comes fromLinkNative, which mapsERROR_NOT_SAME_DEVICEon Windows.Findings
none. MarcZX10's request to fall back only on EXDEV would diverge from the pin, which falls back on every error. A directory or unreadable source still returns false, because the copy's
open/readfails.Suggested action: merge
AI-assisted review (Claude Code) · head
44b2e70022· basemain23b8772462Imported from boykopovar/AnyPS5. Originally posted by throny on 2026-11-23T07:03:38Z.
Review: APPROVED
Review: ✅ re-review at
e88c48ea18: rejecting non-regular sources matchescopy_fileBasis: diff read · head
e88c48ea18Checked
CopyFileContentsnow stats the source first (following symlinks, asstd::filesystem::copy_filedoes) and returns false unless it is a regular file. The old fallback blocked on a FIFO with no writer and copied device nodes;copy_filerejects both. A directory already failed atread.fchmodnow always uses that stat. Returning false matches the pin's!ecand the other failure paths.WtfFileSystemLinks.cpp:158-160forces the cross-device fallback with a FIFO and requires false and no output file (POSIX only, like the other cross-volume cases).Findings
none (the stat-then-open window remains, as it does upstream;
fstaton the opened handle orO_NONBLOCKwould close it)Suggested action: merge
AI-assisted review (Claude Code) · head
e88c48ea18· basemain23b8772462Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T07:24:50Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the tested host behavior supports the implementation, while console behavior and the full CMake test target were not verified.
What I ran
Reviewed head
e88c48ea18ce93f2f6b8d3fc7115698a4b78228cand the prepared diff. No commands or tests were run in this review. The description reports a hand-compiled Linux host harness and convention/debt/diff checks; those results were not independently run here.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The full CMake test target, console behavior, and all repository files outside the reviewed changed files were not verified.
Export.cppandInventoryExports.hppwere excluded from the prepared full-text bundle; their relevant changed hunks were reviewed indiff.patch, but their full files were not read. Reviewed changed files:CMakeLists.txt,WtfExports.hpp,WtfFileSystem.cpp,WtfFileSystemLinks.cpp, andwtf-filesystem-hard-link-or-copy.md. Excluded changed files:Export.cppandInventoryExports.hpp(full text excluded by size).To get this to a good state
Nothing is required.