Skip to content

feat(libkernel): open /dev/random and /dev/urandom for reading - #1777

Merged
adriadam10 merged 2 commits into
boykopovar:mainfrom
MathiasDevelopes:feat/libkernel-random-device
Oct 10, 2026
Merged

adriadam10 merged 2 commits into
boykopovar:mainfrom
MathiasDevelopes:feat/libkernel-random-device

Conversation

@MathiasDevelopes

Copy link
Copy Markdown
Contributor

What

/dev/random and /dev/urandom resolved to files under the guest root that do not exist, so open failed. Titles that read entropy from them then read from the failed descriptor: Planet Coaster (PPSA01736) aborts in sceKernelRead with fd=-1, errno=9.

Opening either path for reading now returns a descriptor backed by the host's null device. read, pread, readv and preadv on it fill the buffer from std::random_device, the source sceRandomGetRandomNumber already uses. As on FreeBSD, both devices behave the same and positioned reads ignore the offset. Opening them for writing (adding entropy) throws. Closing a descriptor, through close or sceKernelClose, forgets it.

Tested

Windows 11, MinGW-w64 15.2.0. guest_filesystem opens both paths and checks read. guest_file_vector checks readv, preadv and pread on /dev/urandom. The full ctest suite passes (476/476), and tools/check_conventions.py --base origin/main passes. With this change, Planet Coaster (PPSA01736) no longer aborts reading /dev/urandom at startup. Linux: built and run only through the shared code; the Linux-only pread, readv and preadv branches are not run on Linux.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

Copilot AI balanced review requested due to automatic review settings October 8, 2026 18:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 10, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

This conflicts with main after today's merges; could you rebase? It passed testing and is otherwise ready.

MathiasDevelopes and others added 2 commits October 10, 2026 09:12
Neither existed under the guest root, so opening them failed and titles
that then read from the descriptor crashed. Opening either for reading
now returns a descriptor whose reads, positioned reads and vector reads
fill the buffer from the host's random device, as
sceRandomGetRandomNumber does. Opening them for writing throws.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@adriadam10

Copy link
Copy Markdown
Collaborator

Rebased onto current main (conflicts were only include/source-list adjacency); build and the affected tests pass on Linux (400/400).

Also added one commit: a "Functional" line in docs/dev/TechnicalDebt.md for the unverified choices (both devices identical, never block, positioned reads ignore the offset, only the exact paths recognised, duped descriptors read as empty, write-open throws).

Merging once CI is green on the new head.

@adriadam10
adriadam10 force-pushed the feat/libkernel-random-device branch from 4e48131 to b49ffef Compare October 10, 2026 07:19
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 10, 2026
@adriadam10
adriadam10 merged commit 41e3491 into boykopovar:main Oct 10, 2026
14 checks passed
SleglJan pushed a commit to SleglJan/AnyPS5 that referenced this pull request Oct 10, 2026
…el-random-device

feat(libkernel): open /dev/random and /dev/urandom for reading
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