Skip to content

fix(libkernel): report getdirentries basep position - #5253

Closed
MarcZX10 wants to merge 2 commits into
boykopovar:mainfrom
MarcZX10:fix/getdirentries-basep-5237
Closed

MarcZX10 wants to merge 2 commits into
boykopovar:mainfrom
MarcZX10:fix/getdirentries-basep-5237

Conversation

@MarcZX10

Copy link
Copy Markdown
Contributor

What

Carry Hussein Kadhim's getdirentries basep fix onto current main, preserving his commit author. Windows now reports the directory entry index at the start of a successful read and leaves basep unchanged on failure. The Linux path likewise writes basep only after a successful read. Add a Linux regression assertion that a too-small-buffer error leaves the caller's basep untouched.

Closes #5237.

Tested

  • Linux: built guest_directory_entry_tests; guest_directory_entries passed (1/1).
  • Linux: guest_directory and guest_fdopendir passed (2/2).
  • The new Linux failure-path assertion fails against unchanged main and passes with this change.
  • Linux: python3 tools/check_conventions.py --base upstream/main passed.
  • The dedicated successful-offset regression target is Windows-only. Hussein's issue report records Windows builds and passing guest_directory_buffer, guest_directory and guest_fdopendir checks. I could not rerun the Windows target here: MinGW configuration stops because libgcc_s_seh-1.dll is unavailable.

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 under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: fix(libkernel): fail getdents on a descriptor that is not open with EBADF #4999 (merge order for the shared libkernel.md debt entry; the runtime fix is independent)
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

husseinkad and others added 2 commits October 13, 2026 15:49
…tdirentries

On Windows getdirentries stored 0 in basep on every call. FreeBSD 11.4
kern_getdirentries stores the descriptor offset the read started at, and
only when the call succeeds. basep now holds the entry index the
descriptor was at before the call, the value lseek returns and accepts,
and a failed call leaves it untouched. The Linux path stored the offset
before the host read and now stores it only on success.

(cherry picked from commit f043f20)
@MarcZX10
MarcZX10 force-pushed the fix/getdirentries-basep-5237 branch from 7c2b593 to a293ce2 Compare October 13, 2026 15:50
@MarcZX10

Copy link
Copy Markdown
Contributor Author

Commit history is now split by authorship: Hussein Kadhim’s original getdirentries fix remains its own commit, and my added Linux failure-path regression is a separate MarcZX100-authored test commit. Linux validation recorded in the PR remains unchanged; the latest conventions check is running.

@simonbronk

Copy link
Copy Markdown
Contributor

On Windows this no longer builds once merged onto current main (cf5f5b53b), although Git merges it without conflicts (Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7; AI-assisted: Claude Code):

core/libs/tests/GuestDirectoryBuffer.cpp:109:13: error: 'getdirentries_nid_postfix' was not declared in this scope

d31e28308 (fix(libkernel): throw for unsupported directory entry names) removed the then-unused getdents_nid_postfix, getdirentries_nid_postfix and __error_nid_postfix declarations from GuestDirectoryBuffer.cpp, and CheckBase here still calls getdirentries_nid_postfix. The test is registered only on Windows, so a Linux build does not compile it. A rebase that restores int APS5_VABI getdirentries_nid_postfix(int, char*, int, std::int64_t*); in the extern "C" block fixes it.

With that line restored, and #4999 also applied: guest_directory_buffer passes 20/20 and the full ctest passes. With this PR and #4999, guest_directory_entries (Linux-only today) also passes on Windows.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.

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.

libkernel: Windows getdirentries stores 0 in basep instead of the read offset (FreeBSD stores it only on success); fix branch ready

4 participants