Repository navigation
Conversation
71c4b0c to
ae37373
Compare
…ndows getdents and getdirentries answered ENOTDIR for a descriptor that is not open. FreeBSD 11.4's kern_getdirentries takes the descriptor with getvnode first, which fails an invalid descriptor with EBADF. An open descriptor that is not a directory keeps ENOTDIR. The existing check for getdents(-1) expected ENOTDIR; it now expects EBADF and also covers a closed descriptor, getdirentries and the POSIX forms. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
ae37373 to
39d6101
Compare
|
Tested on Linux x86-64 (Ubuntu 24.04 in a Colima VM with Rosetta on Apple M4, GCC 13.3), this PR (
AI-assisted: yes (Claude Code). |
|
Thank you for the Linux test, @simonbronk. One correction for the record: the head you tested ( AI-assisted (Claude Code). |
|
Closing: no title is known to reach this. With the queue at 750 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. |
What
On Windows,
getdents,getdirentriesandsceKernelGetdents/sceKernelGetdirentriesansweredENOTDIR(20) for a descriptor that is not open. FreeBSD 11.4'skern_getdirentriestakes the descriptor withgetvnodefirst, andgetvnodefails an invalid descriptor (-1, closed, never opened) withEBADF(9).ReadDirectoryDescriptornow returnsEBADFwhen the descriptor is not open and keepsENOTDIRfor an open descriptor that is not a directory.An existing assertion changes with it:
GuestDirectoryBuffer.cppexpectedENOTDIRforsceKernelGetdents(-1, …). That check came in with the undersized-buffer work, where the descriptor argument was not the subject, and it records what the code answered rather than a source for the number. It now expectsEBADF, and the test also covers a closed descriptor,getdirentriesand the POSIX forms.Not changed, and listed in the TechnicalDebt entry for libkernel: for an open descriptor that is not a directory (and for a pipe or socket) the code still answers
ENOTDIR, where FreeBSD'skern_getdirentriesanswersEINVAL(vp->v_type != VDIR;getvnodeon a non-vnode). The console's answer is not known, so these were left as they were; the test therefore no longer pinsENOTDIRfor an open plain file.No title evidence: found by calling
getdentswith invalid descriptors and comparing with the FreeBSD source. This is FreeBSD conformance.Overlap (checked with
git merge-treeagainst the heads of #4796, #4920, #4922, #4929, #4968, #4989 and #4993): no conflict. The new TechnicalDebt entry sits next to the Windows directory descriptors entry, not at the end of the file, so it does not collide with the entries other PRs append there. No new test file, so no CMake change. Since then #5253 (getdirentriesbasep) conflicts with this PR indocs/dev/debt/libkernel.md(git merge-treeagainstmain8cf6a0b, both clean againstmain) and changes the sameextern "C"block ofGuestDirectoryBuffer.cpp; whichever lands second rebases the debt entry.Tested
Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, in a combined build on
main0214069e3:guest_directory_bufferpasses with the new checks (the test declaresgetdents_nid_postfixand__error_nid_postfixitself:mainremoved them from the file'sextern "C"block in the meantime, and without the declarations the test does not compile); theguest_directory*,guest_fdopendir,guest_file*andguest_filesystemtests pass.DirectoryDescriptor.cppit fails at thegetdents(-1)check (Directory buffer check failed at line 71).python tools/check_conventions.py --base upstream/mainpasses.main0214069e3:guest_directory_buffertakes 0.07 s (ctest, serial, Windows). The fullguest_*/ libc / libkernel group passes with this branch in the combined build (394 of 394, 0 failed; the build also contains the other branches of this series).DirectoryDescriptor.cppis the Windows implementation; the Linux path answers with the host's error), a console, a title run.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt (docs/dev/debt/libkernel.md).mdfiles or images added to the repositoryAI-assisted (Claude Code).
🤖 Generated with Claude Code