feat(libScePosixForWebKit): implement mkostemp #14431
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14431"
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 AlexWhitehouse on 2026-11-01T12:56:41Z.
What
Implements
mkostemp(NIDQP8dYkB8zCU) in libScePosixForWebKit, following FreeBSD 11.4mktemp.c. Upstream WebKit's PlayStation port compilesFileSystemPOSIX.cpp, whoseopenTemporaryFilecallsmkostemp(..., O_CLOEXEC).O_APPEND | O_DIRECT | O_SHLOCK | O_EXLOCK | O_SYNC | O_CLOEXECreturnEINVALbefore the template is read. A null template then throws, where upstream dereferences it.O_APPEND,O_SYNCandO_CLOEXECpass through guest open.O_CLOEXECalso clears native inheritance after creation, withfcntl(F_SETFD)on POSIX andSetHandleInformationon Windows, so libkernel'sOpen.cppis not touched.O_SHLOCKandO_EXLOCKtake a guestflockafter creation, and exclusive wins, as in FreeBSD's open-time locking. A lock failure closes the descriptor, keeps the error and leaves the created file, as FreeBSD does.O_DIRECTthrows throughNotImplemented_nid_no_patch: FreeBSD's cache-bypass semantics have no proven host equivalent. This is recorded in the debt file, and it is why the title doesn't claim full flag support.mkstempandmkostempnow share one temporary-file loop in the newTemporaryFile.cpp, which starts withmktemp.c's notice (lines 1-29, byte for byte).mkstemp's loop moved out ofFilesystem.cpp, and like FreeBSD's_gettempit now also stats the template's parent directory before the first open, failing with that error or ENOTDIR.Tested
tests/GuestPosixFilesystem.cpp(ctestguest_posix_filesystem) now coversmkostemp:F_GETFDshowingFD_CLOEXEConly when requested, both in the guest and natively;EINVALwith the template untouched, including with a null template;mainthe test fails withmkostemp_nid_postfix not implemented.ctest --test-dir build-full -R posix: 25/25 passed. The widerposix|public_headersrun: 90/90 passed.O_DIRECTtest checks were dropped at review:guest_posix_filesystem,public_headersandpublic_headers_compile_0to_63passed, 66/66.python3 tools/check_conventions.py --base origin/main: all conventions checks passed.python3 tools/pr_overlap.py --branch feat/libsceposixforwebkit-mkostemp: no PR shares these exports. #14157 (gethostbyname_r) edits the neighbouring line ofdocs/dev/debt/libScePosixForWebKit.md, and the tool could not compare #14212, a debt-text cleanup that conflicts withmain. Both are text conflicts only; whichever merges second rebases.libsandguest_posix_filesystem_testsat 6746951f0f:ctest -R posix24/24 passed (guest_posix_spawn_flagsis Linux-only). ChangingSetHandleInformation's third argument inTemporaryFile.cppfrom0toHANDLE_FLAG_INHERITmakesguest_posix_filesystemfail at line 59; the restored code passes.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 MarcZX10 on 2026-11-01T13:51:39Z.
Review: COMMENTED
Reviewed — no blocking findings
mkostempis implemented with the flag bits it accepts, the errors it returns for unsupported ones, and the close-on-exec and lock handling I traced through the code, and the helpers it calls exist at head; the one open point is whether BSD-derived code with its licence header is acceptable here, which is a maintainer call.What I ran
6746951f0fc666a60a1301df2339820b943c3513, baseab6f5d32ed5bc9a2e5393bb1ab9b4459b5857bfb(the PR base, which is the currentmain)./usr/bin/python33.11.2, no build.python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14431 --output-dir /dev/shm/reviewer-run/precheck/14431git grepat head:flock_nid_postfix,stat_nid_postfixandFileStat(libkernelinclude/Api.hpp),open_nid_postfixandclose_nid_postfix(libcinclude/Api.hpp).core/libs/tests/GuestPosixFilesystem.cppfrom a head extract: one registration heuristic; the test is already a registered target.TemporaryFile.cppin full, the removals inFilesystem.cppandExport.cpp, and the test diff.CONTRIBUTING.mdline 17 (third-party code as a submodule) anddocs/dev/CONVENTIONS.md; the conventions check passed at head.Results
Precheck report, checks table, unedited (
/dev/shm/reviewer-run/precheck/14431/report.md):The precheck deliberately does not configure, build, or compile AnyPS5.git diff --check ab6f5d32ed5bc9a2e5393bb1ab9b4459b5857bfb...6746951f0fc666a60a1301df2339820b943c3513/usr/bin/python3 tools/check_conventions.py --base ab6f5d32ed5bc9a2e5393bb1ab9b4459b5857bfb --head 6746951f0fc666a60a1301df2339820b943c3513 --title feat(libScePosixForWebKit): implement mkostemp --body /dev/shm/reviewer-run/precheck/14431/pr-body.md/usr/bin/python3 tools/pr_abi_audit.py --base ab6f5d32ed5bc9a2e5393bb1ab9b4459b5857bfb --head 6746951f0fc666a60a1301df2339820b943c3513 --jsonNo changed Python implementation files.No changed tools/ module has an existing sibling tools/tests/test_<module>.py suite.No changed test_*.py files./usr/bin/python3 /marc/AnyPS5/tools/pr_stack_check.py 14431 --repo boykopovar/AnyPS5 --output-dir /dev/shm/reviewer-run/precheck/14431/stackNot run: C++ tests need exact-head binaries, which require a build; the precheck does not build./usr/bin/python3 /dev/shm/reviewer-run/precheck/14431/head-6746951f0fc6-896fc439/tools/pr_test_quality.py --root /dev/shm/reviewer-run/precheck/14431/head-6746951f0fc6-896fc439 --json core/libs/prx/libScePosixForWebKit/CMakeLists.txt core/libs/prx/libScePosixForWebKit/Export.cpp core/libs/prx/libScePosixForWebKit/Filesystem.cpp core/libs/prx/libScePosixForWebKit/TemporaryFile.cpp core/libs/prx/libScePosixForWebKit/include/Api.hpp core/libs/tests/GuestPosixFilesystem.cpp docs/dev/debt/libScePosixForWebKit.mdNo changed Python test module in tools/ can be run as a no-build base-source control.Negative control
Not run. The PR's test runs many flag combinations; the precheck does not run C++ tests.
Findings
Blocking: none.
Non-blocking:
TemporaryFile.cppbegins with the FreeBSD 11.4 licence block (the BSD-3-Clause copyright notice frommktemp.c). The conventions check passes, and the repository already has the same block in libc sources (core/libs/prx/libc/src/FileAndHeap.cppandcore/libs/prx/libc/src/Math.cpp), so this is not a new rule violation.CONTRIBUTING.mdsays third-party code is a submodule, and the code here is derived from FreeBSD, so the maintainers should decide whether copied BSD code belongs in the tree this way.CloseOnExec(0x100000) reaches the guestopenas a flag. That matches FreeBSD'sO_CLOEXECvalue, and the PR says so; it is the intended behaviour.EWOULDBLOCK; the guest mapping is what the test relies on, and I did not check it against the libkernel error table.Sources
mkostempand the flag handling at head:github.com/boykopovar/AnyPS5@6746951f0f/core/libs/prx/libScePosixForWebKit/TemporaryFile.cppgithub.com/boykopovar/AnyPS5@6746951f0f/core/libs/prx/libc/src/FileAndHeap.cppNot verified
TemporaryFile.cppand the guest test were not compiled or run here.SetHandleInformation,_get_osfhandle) was not compiled.conventionswas cancelled twice and re-queued, andeligibility,library-portabilityandreportwere queued at review time.