Skip to content

feat(libkernel): add Linux socketpair support - #1795

Closed
PrintOrb wants to merge 2 commits into
boykopovar:mainfrom
PrintOrb:feature/linux-socketpair-lstat
Closed

PrintOrb wants to merge 2 commits into
boykopovar:mainfrom
PrintOrb:feature/linux-socketpair-lstat

Conversation

@PrintOrb

@PrintOrb PrintOrb commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Implement Linux socketpair() compatibility in libkernel using native Unix-domain sockets and AnyPS5's virtual descriptor infrastructure.

This PR is scoped exclusively to socket-pair support. The overlapping lstat() changes have been removed in favor of the canonical implementation being developed in #1624.

Changes

  • Implement socketpair() for local stream and datagram sockets on Linux.
  • Register socket-pair endpoints as guest virtual file descriptors.
  • Integrate virtual sockets with existing read, write, and close operations.
  • Preserve guest-facing socket I/O through the existing send() and recv() paths.
  • Add socketpair_smoke.cpp covering bidirectional communication, descriptor closure, and invalid arguments.
  • Register the smoke test with CMake/CTest on non-Windows builds.

Validation

  • Successfully built the earlier compatibility changes on Fedora Linux in Distrobox.
  • The previous full CTest run passed 482 of 483 tests. The single failing test, guest_dynamic_loader, also failed on a clean upstream checkout in the same environment.
  • A standalone integration test passed socket creation, bidirectional communication, descriptor cleanup, and use-after-close rejection.
  • Repository conventions checks pass on the updated, rebased branch.

Pending: The newly registered socketpair_smoke CTest target has not yet been built and executed on Linux after the latest changes.

Scope and limitations

  • Linux-specific socket-pair implementation; Windows support is not included.
  • Guest-pointer validation, error-code translation, and additional edge cases may require further refinement.
  • No lstat() implementation is included in the updated PR.

AI assistance disclosure

ChatGPT assisted with implementation, debugging, code review, and test preparation. The contributor reviewed and tested the changes described above.

@PrintOrb PrintOrb changed the title Add Linux socketpair and POSIX lstat compatibility feat(libkernel): add socketpair and lstat support Oct 8, 2026
@PrintOrb
PrintOrb marked this pull request as ready for review October 8, 2026 19:41
@SleglJan SleglJan mentioned this pull request Oct 8, 2026
9 tasks done
@PrintOrb
PrintOrb force-pushed the feature/linux-socketpair-lstat branch from c933361 to 1545914 Compare October 8, 2026 20:15
@MarcZX10

MarcZX10 commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

I reviewed the full diff against #1624 and the current checks. Two follow-ups before this is ready:

  • This adds the same lstat_nid_postfix export and NativeStat path as feat(libkernel): implement lstat #1624. The changes are independent of socketpair, and CONTRIBUTING asks for one topic per PR. Please drop lstat from this PR and keep it focused on socketpair, or coordinate one canonical lstat implementation with feat(libkernel): implement lstat #1624’s author. feat(libkernel): implement lstat #1624 already tests symlinks and dangling symlinks on Linux; this PR’s Windows path silently returns stat results for symlinks.
  • tests/compat/socketpair_smoke.cpp is not referenced by any CMake file, so it is not built or run by CTest. Please register it with the test targets or move its coverage into a registered test. The PR body also says CTest registration was not confirmed.
  • Current-main check: this head is 9 commits behind main 0447793. CONTRIBUTING asks to keep the branch based on current main; please rebase and rerun the checks after resolving the scope and test items.

No upstream Build or Conventions checks are currently reported on this head.

@MarcZX10

MarcZX10 commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Follow-up on the lstat overlap: #1624’s author confirmed they will keep one canonical lstat, and their current fork Build completed successfully across Linux, Windows and relinker jobs. Please keep lstat out of this PR (or agree a handoff with #1624’s author) and retain only the independently scoped socketpair work here; the current duplicate is still open.

@PrintOrb
PrintOrb force-pushed the feature/linux-socketpair-lstat branch from 1545914 to 515531a Compare October 8, 2026 22:56
@PrintOrb PrintOrb changed the title feat(libkernel): add socketpair and lstat support feat(libkernel): add Linux socketpair support Oct 8, 2026
@PrintOrb

PrintOrb commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the follow-up! I've pushed an updated branch that removes the lstat() implementation entirely, leaving #1624 as the canonical implementation.

This PR now contains only the Linux socketpair() changes and their associated tests. I've also registered the smoke test with CMake/CTest, rebased onto current main, and rerun the conventions checker successfully.

The PR description has been updated to reflect the revised scope. Linux execution of the newly registered CTest target is still pending.

I also noticed the automated overlap report flags #1711 and #1839 for socketpair_nid_postfix. I'll review those implementations to ensure we're not duplicating another contribution.

Thanks again for the review and guidance!

@PrintOrb

PrintOrb commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

After reviewing the overlapping PRs, I see that #1711 already provides a more comprehensive socketpair() implementation, including Windows support and additional socket semantics.

Rather than maintaining competing implementations, I'm happy to defer to #1711 as the canonical implementation and assist with testing, debugging, or follow-up improvements where useful.

I'd also be glad to contribute elsewhere in the project if there are other areas that could use assistance. I'm particularly interested in networking, libkernel compatibility, and resolving missing functionality, but I'm open to helping wherever it's needed.

Thanks again for the review and guidance. I appreciate the opportunity to contribute and look forward to continuing to work on the project.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Closing, as you suggested: #1711 implements socketpair on both platforms, with a registered test.

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

Labels

build libkernel needs rebase Conflicts with main, rebase needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants