fix(libkernel): fail open, stat, lstat, access and unlink through a regular file with ENOTDIR on Windows #8195

Merged
xXPBSXx merged 1 commit from upstream-pr/8195 into main 2026-10-20 05:07:05 +00:00
xXPBSXx commented 2026-10-20 02:14:38 +00:00 (Migrated from github.com)

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


What

HasNonDirectoryPrefix_nid_no_patch and NotFoundError_nid_no_patch (new, in FilesystemError.hpp, same logic as the static helper in Stdio.cpp): when the nearest existing ancestor of the host path is not a directory the not-found error becomes ENOTDIR. Used on the failure path of sceKernelOpen (OpenNative), sceKernelStat, lstat_nid_postfix, sceKernelUnlink and the Windows access; no extra host call on success. Remaining calls and the trailing-slash form are not changed; follow-ups for chdir, rename, truncate, chmod, remove, opendir, fopen and utimes are planned as separate PRs by call group.
Fixes #8194

Tested

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

  • guest_filesystem: fails without the changes to Open.cpp, Stdio.cpp and Filesystem.cpp, passes with them.
  • guest_path_case, guest_directory, guest_working_directory, guest_fstat_fault and guest_file_vector pass.
  • python tools/check_conventions.py --base upstream/main: passes.
  • Not tested: Linux/macOS (unchanged paths), a console, a title run.

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:4930029059 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8195). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-20T02:14:38Z. --- ### What `HasNonDirectoryPrefix_nid_no_patch` and `NotFoundError_nid_no_patch` (new, in `FilesystemError.hpp`, same logic as the static helper in `Stdio.cpp`): when the nearest existing ancestor of the host path is not a directory the not-found error becomes ENOTDIR. Used on the failure path of `sceKernelOpen` (`OpenNative`), `sceKernelStat`, `lstat_nid_postfix`, `sceKernelUnlink` and the Windows `access`; no extra host call on success. Remaining calls and the trailing-slash form are not changed; follow-ups for chdir, rename, truncate, chmod, remove, opendir, fopen and utimes are planned as separate PRs by call group. Fixes #8194 ### Tested Windows 10 (19045), MinGW-w64 GCC 15.2.0, Release, on upstream/main + this commit: - `guest_filesystem`: fails without the changes to `Open.cpp`, `Stdio.cpp` and `Filesystem.cpp`, passes with them. - `guest_path_case`, `guest_directory`, `guest_working_directory`, `guest_fstat_fault` and `guest_file_vector` pass. - `python tools/check_conventions.py --base upstream/main`: passes. - Not tested: Linux/macOS (unchanged paths), a console, a title run. ### 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)
github-actions[bot] commented 2026-10-20 02:17:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T02:17:39Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 7447 core/libs/prx/libkernel/File/src/Stdio.cpp L976-977
PR 8149 core/libs/prx/libkernel/File/src/Open.cpp L372-373

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 5021 core/libs/prx/libkernel/File/src/Open.cpp
core/libs/prx/libkernel/File/src/Stdio.cpp
PR 6044 core/libs/tests/GuestFilesystem.cpp
PR 6879 core/libs/prx/libkernel/File/src/Stdio.cpp
PR 6977 core/libs/prx/libkernel/File/src/Stdio.cpp
PR 7121 core/libs/prx/libkernel/File/src/Open.cpp
core/libs/prx/libkernel/File/src/Stdio.cpp
PR 7201 core/libs/prx/libkernel/File/src/Open.cpp
core/libs/prx/libkernel/File/src/Stdio.cpp
PR 7202 core/libs/tests/GuestFilesystem.cpp
PR 7332 core/libs/prx/libkernel/File/src/Open.cpp
core/libs/prx/libkernel/File/src/Stdio.cpp
PR 7437 core/libs/prx/libkernel/File/src/Open.cpp
PR 7949 core/libs/prx/libkernel/File/src/Stdio.cpp
core/libs/tests/GuestFilesystem.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6281787439 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8195#issuecomment-6281787439). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-20T02:17:39Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | [PR 7447](https://www.github.com/boykopovar/AnyPS5/pull/7447) | `core/libs/prx/libkernel/File/src/Stdio.cpp` [L976-977](https://github.com/boykopovar/AnyPS5/blob/329b9aa1a7a413b562263f47a6b6a5863bfc205f/core/libs/prx/libkernel/File/src/Stdio.cpp#L976-L977) | | | | [PR 8149](https://www.github.com/boykopovar/AnyPS5/pull/8149) | `core/libs/prx/libkernel/File/src/Open.cpp` [L372-373](https://github.com/boykopovar/AnyPS5/blob/329b9aa1a7a413b562263f47a6b6a5863bfc205f/core/libs/prx/libkernel/File/src/Open.cpp#L372-L373) | | | Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `core/libs/prx/libkernel/File/src/Open.cpp`<br>`core/libs/prx/libkernel/File/src/Stdio.cpp` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/tests/GuestFilesystem.cpp` | | [PR 6879](https://www.github.com/boykopovar/AnyPS5/pull/6879) | `core/libs/prx/libkernel/File/src/Stdio.cpp` | | [PR 6977](https://www.github.com/boykopovar/AnyPS5/pull/6977) | `core/libs/prx/libkernel/File/src/Stdio.cpp` | | [PR 7121](https://www.github.com/boykopovar/AnyPS5/pull/7121) | `core/libs/prx/libkernel/File/src/Open.cpp`<br>`core/libs/prx/libkernel/File/src/Stdio.cpp` | | [PR 7201](https://www.github.com/boykopovar/AnyPS5/pull/7201) | `core/libs/prx/libkernel/File/src/Open.cpp`<br>`core/libs/prx/libkernel/File/src/Stdio.cpp` | | [PR 7202](https://www.github.com/boykopovar/AnyPS5/pull/7202) | `core/libs/tests/GuestFilesystem.cpp` | | [PR 7332](https://www.github.com/boykopovar/AnyPS5/pull/7332) | `core/libs/prx/libkernel/File/src/Open.cpp`<br>`core/libs/prx/libkernel/File/src/Stdio.cpp` | | [PR 7437](https://www.github.com/boykopovar/AnyPS5/pull/7437) | `core/libs/prx/libkernel/File/src/Open.cpp` | | [PR 7949](https://www.github.com/boykopovar/AnyPS5/pull/7949) | `core/libs/prx/libkernel/File/src/Stdio.cpp`<br>`core/libs/tests/GuestFilesystem.cpp` |
droid2299 commented 2026-10-20 02:44:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by droid2299 on 2026-10-20T02:44:51Z.


Independent Windows validation on commit bbb5b7d2f:

  • Windows 11 (build 26200), MinGW-w64 GCC 15.2.0, Release
  • guest_filesystem: passed
  • guest_path_case, guest_directory, guest_working_directory, guest_fstat_fault, and guest_file_vector: 5/5 passed
  • git diff --check HEAD^ HEAD: passed
  • python tools/check_conventions.py --base HEAD^ --head HEAD: passed

The focused ENOTDIR regression and adjacent filesystem coverage pass for me.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6282123037 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8195#issuecomment-6282123037). Originally posted by [droid2299](https://github.com/droid2299) on 2026-10-20T02:44:51Z. --- Independent Windows validation on commit `bbb5b7d2f`: - Windows 11 (build 26200), MinGW-w64 GCC 15.2.0, Release - `guest_filesystem`: passed - `guest_path_case`, `guest_directory`, `guest_working_directory`, `guest_fstat_fault`, and `guest_file_vector`: 5/5 passed - `git diff --check HEAD^ HEAD`: passed - `python tools/check_conventions.py --base HEAD^ --head HEAD`: passed The focused ENOTDIR regression and adjacent filesystem coverage pass for me.
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!8195
No description provided.