fix(libc): fail fopen and freopen of a directory for writing with EISDIR on Windows #8192

Merged
xXPBSXx merged 1 commit from upstream-pr/8192 into main 2026-10-20 03:22:17 +00:00
xXPBSXx commented 2026-10-20 02:02:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-20T02:02:58Z.


What

New OpenFailure helper in FileAndHeap.cpp: when a write-mode open fails with EACCES and the path is a directory, the error is EISDIR (21), as vn_open_vnode answers. fopen and freopen use it. A read-mode open of a directory is not changed: FreeBSD succeeds there, the Windows CRT refuses with EACCES (not part of this PR).
Fixes #8191

Tested

Windows 10 (19045), MinGW-w64 GCC 15.2.0, Release, on upstream/main 6bd669e40c + this commit:

  • guest_filesystem: fails without the change to FileAndHeap.cpp (new cases for "w", "wb", "r+", "a" on a directory), passes with it; guest_append_streams passes.
  • python tools/check_conventions.py --base upstream/main: passes.
  • Not tested: Linux/macOS, a console, a title run, the freopen path (same helper, no case of its own).

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; no silent stubs added
  • 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
  • Unblocks: none
  • AI-assisted: yes

AI-assisted (Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4929942041 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8192). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-20T02:02:58Z. --- ### What New `OpenFailure` helper in `FileAndHeap.cpp`: when a write-mode open fails with EACCES and the path is a directory, the error is EISDIR (21), as `vn_open_vnode` answers. `fopen` and `freopen` use it. A read-mode open of a directory is not changed: FreeBSD succeeds there, the Windows CRT refuses with EACCES (not part of this PR). Fixes #8191 ### Tested Windows 10 (19045), MinGW-w64 GCC 15.2.0, Release, on upstream/main 6bd669e40c + this commit: - `guest_filesystem`: fails without the change to `FileAndHeap.cpp` (new cases for "w", "wb", "r+", "a" on a directory), passes with it; `guest_append_streams` passes. - `python tools/check_conventions.py --base upstream/main`: passes. - Not tested: Linux/macOS, a console, a title run, the `freopen` path (same helper, no case of its own). ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw; no silent stubs added - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] AI-assisted: yes AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!8192
No description provided.