feat(posix): implement mkstemp and isatty #1613
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1613"
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 NumberGuan on 2026-10-08T14:46:23Z.
What
Implement
mkstempandisattyinlibScePosixForWebKitfor the homebrew imports reported in #1578.mkstempuses the guest path resolver and existingopenimplementation, creates files exclusively with read/write access and mode 0600, and handles collisions without truncating existing files. Its trailing-X and fixed-name behavior follows FreeBSD 9.isattydistinguishes terminals, non-terminal files/pipes/sockets (ENOTTY), and invalid descriptors (EBADF), following FreeBSD's terminal check. Windows checks console handles and handles invalid CRT descriptors without aborting.The socket check calls
GuestSocketIsOpen_nid_no_patch, a C host helper whose export survives NID patching. This fixes the patched module load failure (Windows error 127) reported in the review. Internal socket callers keep using the existing registry implementation.Refs #1578. No dependency on another PR. Console verification and existing Windows file-permission limits are recorded in TechnicalDebt.
Tested
Windows x64, Release, WinLibs MinGW-w64 GCC 15.2.0 UCRT POSIX:
.prxlibraries loaded with zero failures using the standalone loader from #1828; the loader is statically linked and starts without unpatched guest libraries loaded.git diff --checkpassed.git range-diffconfirms the original feature commit is unchanged after rebasing.31b26d7d: Windows and Linux builds and CTest passed, with 489 registered tests / 203 skipped on Windows and 498 / 25 skipped on Linux; zero failures. Conventions passed.NUL. Terminal tests run when a console or pseudo-terminal is available.Checklist
main(f1451396); no other open PR implements the same functionsImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-08T14:46:54Z.
Progress report (
2e375a5→f9be276)📈 System libraries: 85.23% (+0.01%, +2 implemented functions)
✅ 2 implemented
isatty_nid_postfixmkstemp_nid_postfixImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-08T14:51:06Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)docs/dev/TechnicalDebt.mdL238__error_nid_postfix__error_nid_postfix__error_nid_postfix__error_nid_postfix__error_nid_postfix__error_nid_postfix__error_nid_postfix__error_nid_postfixdocs/dev/TechnicalDebt.mdL238docs/dev/TechnicalDebt.mdL238core/libs/prx/libkernel/Socket/src/Udp.cppL182__error_nid_postfix__error_nid_postfixdocs/dev/TechnicalDebt.mdL238docs/dev/TechnicalDebt.mdL238Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-08T20:16:24Z.
On Windows the patched
libScePosixForWebKit.prxfrom this PR fails to load, so a title that imports it stops before start-up. OpenGL Showcase (PPSA99005) stops atmkstemponmain(FAIL: unresolved ELF import uEtgPWgPxOk from libScePosixForWebKit.prx); with this PR it no longer gets that far and ends withFailed to load module: ...\libs\libScePosixForWebKit.prx/GetLastError: 127 - The specified procedure could not be found.The cause is the new call to
GuestSockets::IsOpen, a C++ export of libkernel.nid_patcherkeeps a host export's name only if libc exports it too, it ends in_nid_no_patch, or it starts withSDL_. Every other export is renamed to its hash (core/libs/nid/src/NidResolver.cpp:40-62). So the patchedlibkernel.prxno longer has_ZN12GuestSockets6IsOpenEi, while the import inlibScePosixForWebKit.prxkeeps that name. CI doesn't see it because ctest loads the libraries fromlibs/unpatched.Tested fix: export a wrapper
extern "C" bool GuestSocketIsOpen_nid_no_patch(int descriptor)from libkernel (asKernelSetSocketPoller_nid_no_patchdoes inSocket/include/SocketPoll.hpp) and call it fromFilesystem.cpp. With that, the module loads, PPSA99005 gets pastmkstempand stops atsceVideoOutGetResolutionStatus(#1714), and the 3 POSIX tests pass.Windows 11, Radeon 860M, MinGW-w64 GCC 15.2.0, Release,
main4b6ab6bb; title relinked withrelinker --windowsand run with the patchedbuild/core/libs/libs/*.prx.Tested with AI assistance (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T21:36:59Z.
Checked the diff, the
mkstempcollision/wrap logic (fixed names, all-Xsuffix, no truncation of existing files),isattyerrno mapping against FreeBSD, the TechnicalDebt entry and the_nid_no_patchhelper (same pattern asKernelSetSocketPoller_nid_no_patch).guest_posix_filesystempasses locally on Linux; Windows and Linux CI are green on this head. Merging.Rebased onto current
mainto resolve the TechnicalDebt conflict with #1823 (both lines kept, no code change).