fix(libkernel): honour open flags when Windows falls back to a directory descriptor #1628
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1628"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-08T15:17:07Z.
What
On Windows
_wopencannot open a directory, sosceKernelOpenfalls back to a directory descriptor when the path is a directory. The fallback ignored the flags:O_CREAT | O_EXCLon an existing directory returned a descriptor instead ofEEXIST, and write access returned a read-only descriptor instead ofEISDIR.The fallback now follows FreeBSD
vn_open_cred/vn_open_vnode(sys/kern/vfs_vnops.c):O_CREAT | O_EXCL:EEXISTO_CREATwithoutO_EXCL,O_TRUNC,O_WRONLYorO_RDWR:EISDIRLinux opens directories natively and already returns these errors.
Tested
Linux (Ubuntu 24.04, GCC 13, Release):
guest_filesystempasses with--repeat until-fail:3; the new assertions open the test directory with each flag combination above and a plain read-only open. On Linux they check host behaviour, which is the reference; the Windows job runs the same assertions against the changed fallback. Windows:Open.cppcompiles with MinGW-w64 GCC 13 (-Wall -Wextra -fsyntax-only); not run on Windows locally.check_conventions.pypasses. No title run.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by klosixgaming-arch on 2026-10-08T15:34:22Z.
Review: APPROVED
LGTM. Clean fix that makes the Windows directory open fallback properly honor open flags, matching FreeBSD behavior. The flag checking logic is correct - EEXIST for O_CREAT|O_EXCL on existing directories, EISDIR for write access or truncation, and allowing plain read-only opens as before. Test coverage is thorough with all failing flag combinations verified plus confirmation that valid directory opens still work.
Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-08T17:37:05Z.
Fork CI while the upstream run waits for approval: Build run, all jobs green on ce3c5bf8 (Linux 466/466, Windows 457/457, relinker on Linux, macOS and Windows). It builds the branch head, not the merge with
main.Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T10:00:50Z.
First Windows run, since the description says it was only compiled with MinGW. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. #1624, #1628, #1633 and #1634 merged together onto
mainb7218b3c.guest_filesystem, which carries this PR's directory-fallback cases, passes.🤖 Addressed by Claude Code