Skip to content

feat(libc): implement guest gethostname - #2019

Closed
QRMOE wants to merge 5 commits into
boykopovar:mainfrom
QRMOE:feat/libc-hostname
Closed

QRMOE wants to merge 5 commits into
boykopovar:mainfrom
QRMOE:feat/libc-hostname

Conversation

@QRMOE

@QRMOE QRMOE commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

What

Updated source branch: a4e3ff0d2. GitHub still shows the previous closed PR head b9c5a3a8; a maintainer needs to reopen the PR to refresh its diff. The behavior and validation below describe the updated source branch.

Implements gethostname (-nvxBWa0iDs) with the stable guest hostname AnyPS5. The guest receives this name on every host; the implementation never queries or copies the PC's DNS hostname, Unix nodename or environment. This addresses the host-name exposure raised in the close note.

Preserves the existing FreeBSD buffer behavior: bounded copying, guest ENAMETOOLONG=63, null-buffer queries and unchanged guest errno on success. There are no host API calls or dynamic allocations in the implementation. Tests now verify the guest identity, buffer guards, every capacity from zero through hostname length + 2, maximum size_t capacity, null queries, success errno and thread-local error isolation. TechnicalDebt records the fixed-name policy and unverified console hostname configuration and sysctl/resolver integration.

babyhuey's report supplies the requested current-main failure: XashPS5 (PPSA19111) stops at missing gethostname, and the previous branch moves it to missing realpath on Linux and Windows. That report tested the previous head, before this identity change; it is third-party evidence and has not been independently rerun here. No claim that this revision starts the title is made.

Tested

Windows 11, WinLibs MinGW-w64 GCC 15.2.0 UCRT/POSIX/SEH, Ninja Release; BUILD_TESTING=ON, ANYPS5_ENABLE_SPIRV_TOOLS=ON.

  • The new identity regression fails against the old host-name implementation.
  • On the original PR base, guest_hostname and guest_errors each passed five consecutive runs with this fix.
  • Complete default project build passed with the branch merged into main 5edae35361e9b7f7061f28c6e80ed075312b8105. On that tree, guest_hostname and guest_errors each passed five consecutive runs; a second build had no work to do.
  • Conventions and diff whitespace passed. Test registration: 552 executables, none built but unregistered.
  • A separate compilation of the production source has no host identity API dependency.
  • Published branch head a4e3ff0d2bee6582651fa876f1a0e188b93cf2e6 includes current main. Its complete source tree exactly matches the tree used for the successful full build and focused tests.

Not tested: Linux or macOS for this revision, console, games or the complete CTest suite. Previous Linux approvals and title reports apply to the earlier head.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR
  • No new code comments
  • No silent success stubs introduced
  • Investigation notes, reports and images kept outside the repository
  • No third-party dependencies added
  • Generic behavior, not specific to one title
  • Depends on: none
  • AI-assisted: yes, OpenAI Codex assisted with code, tests, validation and this description

QRMOE added 3 commits October 9, 2026 07:10
AI-assisted: yes. Implements the reported homebrew import with FreeBSD buffer behavior and the host hostname.
AI-assisted: yes. Builds the implementation and registers guest_hostname with a 20-second timeout.
AI-assisted: yes. Validates native hostname, every boundary capacity, buffer guards, truncation, null queries and thread-local errno.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed the complete three-file diff at faba0016408ba09181cbaeef4fb639ee6580a4f7. The null-buffer query path is consistent with the cited FreeBSD implementation, which passes the destination pointer and length to sysctl; Windows' GetComputerNameExA also documents a null-buffer size query. The bounded copy and guest ENAMETOOLONG behavior match the source described in the PR.

Independent Linux/GCC 12.2 validation: guest_hostname is registered and passed (1/1, 0.02 s), check_conventions.py passed, and git diff --check passed. GitHub reports no checks on this head yet. The Windows-specific path remains supported by the author's reported Windows 11 run; I could not execute that path on this Linux host. I found no blocking issue in the diff.

References: FreeBSD gethostname.c (https://raw.githubusercontent.com/freebsd/freebsd-src/main/lib/libc/gen/gethostname.c); Microsoft GetComputerNameExA documentation (https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getcomputernameexa).

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previously reviewed head is unchanged. I confirm the three-file diff and guest_hostname coverage; independent Linux/GCC 12.2 testing passed, and the author reports the Windows hostname path and test pass. The Windows API behavior is supported by the cited GetComputerNameExA docs. GitHub reports no checks for this head, and I cannot run the Windows-specific path in this Linux environment; no blocking issue found.

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Progress report (d70b899 → b9c5a3a)

📈 System libraries: 84.7% (+0.01%, +1 implemented functions)

✅ 1 implemented
Library Name
libc gethostname_nid_postfix

QRMOE added 2 commits October 9, 2026 13:27
AI-assisted: yes. Moves hostname test registration to avoid boykopovar#2170 overlap. The full current-main build and focused Windows tests pass; implementation and test source are unchanged.
@adriadam10

Copy link
Copy Markdown
Collaborator

Closing for now: no title stops on gethostname on main, and the description says so (the reference is an import audit, #1578). #1594, the same export, was closed on 2026-10-08 for that reason, and it also hands the host's machine name to the guest, which this PR doesn't address.

The implementation and test look sound. Feel free to reopen when a title's next stop on main is gethostname, with the log line, and say how the host name is exposed to the guest.

@adriadam10 adriadam10 closed this Oct 9, 2026
@babyhuey

Copy link
Copy Markdown
Contributor

This is now a title's next stop on current main, so here is the log line the close note asked for, plus a check of this branch.

Checked b9c5a3a merged onto main c963432 (clean), Linux (Ubuntu 24.04, GCC 13) and Windows 11 (MinGW-w64 GCC from WinLibs), Release.

  • guest_hostname passes 5/5 on both (--repeat until-fail:5); no CRT assertion dialog on Windows.
  • On main (catalog runs on 2edaf7f Linux and 0c0dc1e Windows) and with this branch:
Title main with this branch (Linux and Windows)
XashPS5 (PPSA19111) undefined symbol: -nvxBWa0iDs (gethostname) vhtcIgZG-Lk (realpath)

Example lines for XashPS5 (PPSA19111): main Windows FAIL: unresolved ELF import -nvxBWa0iDs (gethostname) from libSceLibcInternal.prx; with this branch, Linux app.elf: symbol lookup error: app.elf: undefined symbol: vhtcIgZG-Lk, Windows FAIL: unresolved ELF import vhtcIgZG-Lk from libSceLibcInternal.prx.

This only covers the title-stop half of the close note; the point about handing the host's machine name to the guest is still open.

@QRMOE

QRMOE commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

The host-name exposure is addressed on the updated source branch at a4e3ff0d2. gethostname now returns the fixed guest name AnyPS5 without querying the PC's hostname, nodename or environment. Bounded copying, null queries, guest ENAMETOOLONG and success errno preservation remain covered by tests. TechnicalDebt records the fixed-name policy and unverified console hostname configuration and sysctl/resolver integration.

Windows 11, MinGW-w64 GCC 15.2.0, Ninja Release: the complete default build passed with the branch merged into main 5edae3536; guest_hostname and guest_errors each passed five consecutive runs. The new identity regression fails against the old implementation. Conventions, whitespace and test registration passed. The published branch's complete source tree matches the tested tree.

babyhuey's XashPS5 report supplies the requested runtime-stop evidence for the previous revision. Linux and title retesting of this new hostname policy are still pending; no new title-unblocking claim is made.

Could this PR be reopened for review of the updated branch? The closed PR still shows head b9c5a3a8, so its current diff does not include this fix. The description now links the updated branch and lists the validation limits.

AI-assisted: yes, OpenAI Codex assisted with the change, tests, validation and this comment.

@babyhuey

Copy link
Copy Markdown
Contributor

@QRMOE same question as on #2024: gethostname is still XashPS5's (PPSA19111) next stop on main 57f96fd, and this branch merges cleanly. If you'd like, I can open it from my fork with your commits and authorship kept. The review point about handing the host's machine name to the guest is still open, so it would need an answer to that first; do you have a preference for what the guest should see?

@QRMOE

QRMOE commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

@babyhuey Yes, please go ahead and open it from your fork. Please preserve my original commits and authorship, credit @QRMOE in the new PR description, and retain the original author credit if rebasing or squashing.

My preference is the fixed guest name AnyPS5, without exposing the PC's machine name. This is already implemented on the updated source branch at a4e3ff0d2. Please use that updated branch: the closed PR still shows the old head b9c5a3a8 and its diff does not include the change.

The full Windows build passed with main 5edae3536, and guest_hostname and guest_errors each passed five consecutive runs. Linux and XashPS5 retesting of this revision are pending, so your proposed testing would help. TechnicalDebt records the fixed-name policy and the remaining console hostname configuration and sysctl/resolver gaps.

Thank you for helping carry this forward. Please link the replacement PR here so I can follow it.

AI-assisted: yes, OpenAI Codex assisted with the implementation, validation and this reply.

@babyhuey babyhuey mentioned this pull request Oct 10, 2026
9 tasks done
@babyhuey

Copy link
Copy Markdown
Contributor

@QRMOE opened as #2968 from your updated branch (a4e3ff0, the fixed AnyPS5 name), rebased onto main 9c5d67f with your seven commits and authorship kept; the two merge commits are dropped since main takes linear history. guest_hostname and guest_errors pass 5/5 on Linux and Windows, and XashPS5 goes on to realpath on both.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants