Repository navigation
Conversation
…rt at the descriptor position Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…nd set FD_CLOEXEC FreeBSD 11's fdopendir sets FD_CLOEXEC and reads the first batch of entries from the descriptor's current offset (lib/libc/gen/opendir.c, __opendir_common with use_current_pos). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Linux validation (Ubuntu 24.04, GCC 13.3, Release), this PR's commits on AI-assisted: yes |
|
Thank you for the Linux validation, @coltken95 ( AI-assisted (Claude Code). |
|
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. |
What
fdopendir(added in #4569) opens the directory stream at the first entry and does not setFD_CLOEXEC; its TechnicalDebt entry lists both as differences from FreeBSD. FreeBSD 11'sfdopendirfirst calls_fcntl(fd, F_SETFD, FD_CLOEXEC)and then__opendir_common(fd, ..., true); withuse_current_posit reads the first batch of entries from the descriptor's current offset ("For the fdopendir() case, the initial seek position must be preserved", same file). This PR does both:fdopendirsetsFD_CLOEXECthrough the existingfcntl(F_SETFD, which stores the one flag the word has) before anything else, so a descriptor that is not open still fails withEBADF, and a non-directory still fails withENOTDIRwith the flag set, as in FreeBSD.On Windows the guest directory descriptor already keeps a cursor (
lseek; the test coverslseekonly, notgetdirentries); the stream now skips that many entries of the host listing, which assumes the descriptor and the stream list the directory in the same order (both come from the same host enumeration, with.and..first).On Linux the stream is opened with the host
fdopendiron a duplicate of the descriptor, which shares its position. This assumes the guest descriptor number is the host descriptor number there.The debt entry is updated in
docs/dev/debt/libSceLibcInternal.md(the two differences are removed; the Windows ordering assumption and the untested Linux path are stated).Tested
Windows 10, MinGW GCC 15.2.0, Ninja Release,
-j2: the test-only commit fails (guest_fdopendiraborts with exit code0xc0000409at the new checks); with the changeguest_directory,guest_statvfs,guest_fstatvfs_conversion,guest_fstatvfs,guest_fdopendir,guest_posix_filesystem,guest_directory_buffer,guest_directory_rewindandguest_directory_closepass (9 of 9);python tools/check_conventions.py --base upstream/mainpasses.Built with the
3rdparty/libusb-cmakesubmodule checked out locally at the pinned commitbea6567b(currentmainrequires it; it was empty in my checkout). The branch is based on584cc4c57;git merge-treeagainstmain43e3a70f8reports no conflict.The nine tests were rerun on the final commit (
8e99582f6, base584cc4c57): build without errors, 9 of 9 pass,check_conventionspasses.Not tested by me: Linux (see the validation below). The Linux path (
dup+ hostfdopendir) was not built or run. The "starts at the current position" check in the test is Windows-only (#ifdef _WIN32); theFD_CLOEXECand error checks run on both.Linux validation by coltken95 in the comments (13 October, 11:12Z; Ubuntu 24.04, GCC 13.3, Release; this PR's commits on
mainat77b9f7270):guest_fdopendirpasses, and withmain's sources and this PR's test it aborts. That covers the Linux path that the line above says was not run by me.git merge-treeof the current head8e99582f6againstmain068ab2aba(13 October) is clean.Not measured on a console: the behavior follows the FreeBSD 11.0 source, not a PS5 run.
Checklist
Merges onto current
mainwithout conflict (checked withgit merge-treeagainst43e3a70f8; the branch is based on584cc4c57); no other open PR implements the same functionsOne 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 TechnicalDebtNo notes, investigation
.mdfiles or images added to the repositoryNew third-party code is a submodule built from source (n/a, none added; the local
libusb-cmakeclone is build infrastructure and not part of this PR)Generic behaviour, not specific to one title
Depends on: none
Unblocks: none
AI-assisted: yes (Claude Code)
AI-assisted (Claude Code).
🤖 Generated with Claude Code