feat(libc): implement gethostname #1975
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1975"
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 Pedroj-64 on 2026-10-09T03:37:26Z.
What
gethostnamewas not exported.It writes the fixed name
PS5and returns 0. A buffer shorter than the name returns -1 withENAMETOOLONG(63), following FreeBSDlib/libc/gen/gethostname.c. A null buffer returns -1 without settingerrno. The namePS5has no known source and the console's behaviour on a short buffer is unverified; both are recorded in technical debt. No title was run, so no log is attached.core/libs/prx/libSceLibcInternal/Export.cpp:gethostname.guest_thread_atexittest: full name, exact fit, short buffer, zero length and null buffer.TechnicalDebt.md: entry under unknown function info.Tested
Linux (CachyOS), GCC 16.2.1, Release.
guest_thread_atexitpasses.tools/check_conventions.py --base upstream/mainpasses.Not tested on Windows or macOS.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T04:08:31Z.
The tests cover the behavior this patch chose, but they do not establish that the guest behavior is correct. The body says two titles import
gethostname, while CONTRIBUTING.md says an import list alone does not show that a title reaches the function; it also asks for a reproduced failure and its log. Could you add that evidence, and a source or hardware trace for returning the fixed stringPS5and truncating successfully on short buffers? These are the core semantics, and the TechnicalDebt entry currently says both are unverified. Until that is grounded, I cannot approve the implementation under the project rule that functions do what they are supposed to or throw.Imported from boykopovar/AnyPS5. Originally posted by Pedroj-64 on 2026-10-09T04:15:48Z.
Thanks for the careful review, you're right on both points.
Short buffer. I checked FreeBSD's
lib/libc/gen/gethostname.c, the base of the PS5 system software. It callssysctl(CTL_KERN, KERN_HOSTNAME)and, onENOMEM, setserrno = ENAMETOOLONGand returns -1. It does not truncate and succeed. I changed the implementation to match and updated the tests and the TechnicalDebt entry (Linux: full suite, 494 tests, and the conventions check pass; Windows is left to CI). It is a FreeBSD source, not a console trace, so it stays recorded as unverified on hardware.The
PS5name. I don't have a source or trace for it and won't claim one. I found no host name in the other open-source implementations I checked (for example shadPS4'sprocess.cpp). It stays a documented placeholder in TechnicalDebt. If you know a source, or someone can printgethostnameon a console, I'll gladly use it.Import evidence. You're right that an import list doesn't show the function is reached. I don't have PPSA99039 or PPSA99001 to run, so I can't provide a reproduced failure or log. I removed that claim from the PR body and the TechnicalDebt entry.
If you'd prefer this wait for a real trace, or be implemented differently, I'm open to that. Thanks again.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T04:17:23Z.
The FreeBSD source resolves the short-buffer behavior, and removing the import claim was the right correction. I still cannot approve:
PS5has no source or console trace, so the implementation returns a guessed hostname; the PR also has no demonstrated call/failure or other concrete use. TechnicalDebt records the uncertainty but does not make this behavior correct under the project rule. I recommend holding this export until the hostname can be grounded, rather than merging a placeholder that titles will observe.Imported from boykopovar/AnyPS5. Originally posted by Pedroj-64 on 2026-10-09T04:29:02Z.
Thanks for the review, Marc. Without a source or console trace for the host name, this would return a guessed value that titles can observe, so I'm closing it rather than merging a placeholder. The branch stays in my fork. If anyone can print
gethostnameon a console, or has a source for the value, I'll reopen it.Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T10:03:53Z.
First Windows run, since the description says it wasn't tested on Windows.
Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Merged onto
mainb7218b3ctogether with nine other small libc/libkernel PRs: #1976, #1977, #1859, #1685, #1676, #1675, #1641, #1656, #1807.guest_thread_atexitpasses.🤖 Addressed by Claude Code
Pull request closed