fix(libkernel_sys): fail link, symlink, pathconf and fchmodat through a regular file with ENOTDIR #8522

Merged
xXPBSXx merged 1 commit from upstream-pr/8522 into main 2026-10-21 18:47:52 +00:00
xXPBSXx commented 2026-10-20 14:51:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-20T14:51:23Z.


What

link, symlink, pathconf and fchmodat answered ENOENT for a path whose directory part is a regular file, such as file/child; FreeBSD 11.4 answers ENOTDIR (vfs_cache_lookup, sys/kern/vfs_cache.c:2104-2105), as the open, stat, unlink, chmod, truncate, utimes, rename, chdir, remove and opendir changes before this one already do. The not-found branches of the four calls now ask HasNonDirectoryPrefix first: the source and the destination parent of link, the parent of symlink, the status error and not-found branch of pathconf, and the chmod failure of fchmodat. readlink and readlinkat are left to #8312.
Fixes #8521
Follow-up to #8195, #8199 and #8200 (merged). git merge-tree against upstream/main, #8312, #5528, #6942 and #8217 is clean; pr_overlap was not run.

Tested

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

  • guest_kernel_sys: fails at the new cases (guest errno 2) with libkernel_sys/Export.cpp taken back to main, passes with the change (3 of 3 runs). New cases: pathconf, fchmodat, symlink and both link forms through file.txt/child return -1 with errno 20.
  • The other tests that call these functions pass: guest_filesystem, guest_path_name_length, guest_truncate_extend, guest_poll, guest_select, guest_select_wait, guest_kqueue.
  • python tools/check_conventions.py --base upstream/main: passes.
  • Not tested: Linux and macOS (the fchmodat branch for them changes the same way but is not built here), 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:4937599540 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8522). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-20T14:51:23Z. --- ### What `link`, `symlink`, `pathconf` and `fchmodat` answered `ENOENT` for a path whose directory part is a regular file, such as `file/child`; FreeBSD 11.4 answers `ENOTDIR` (`vfs_cache_lookup`, sys/kern/vfs_cache.c:2104-2105), as the open, stat, unlink, chmod, truncate, utimes, rename, chdir, remove and opendir changes before this one already do. The not-found branches of the four calls now ask `HasNonDirectoryPrefix` first: the source and the destination parent of `link`, the parent of `symlink`, the status error and not-found branch of `pathconf`, and the `chmod` failure of `fchmodat`. `readlink` and `readlinkat` are left to #8312. Fixes #8521 Follow-up to #8195, #8199 and #8200 (merged). `git merge-tree` against `upstream/main`, #8312, #5528, #6942 and #8217 is clean; `pr_overlap` was not run. ### Tested Windows 10 (19045), MinGW-w64 GCC 15.2.0, Release, on upstream/main 75787d2f64 + this commit: - `guest_kernel_sys`: fails at the new cases (`guest errno 2`) with `libkernel_sys/Export.cpp` taken back to main, passes with the change (3 of 3 runs). New cases: `pathconf`, `fchmodat`, `symlink` and both `link` forms through `file.txt/child` return -1 with errno 20. - The other tests that call these functions pass: `guest_filesystem`, `guest_path_name_length`, `guest_truncate_extend`, `guest_poll`, `guest_select`, `guest_select_wait`, `guest_kqueue`. - `python tools/check_conventions.py --base upstream/main`: passes. - Not tested: Linux and macOS (the `fchmodat` branch for them changes the same way but is not built here), 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 15:00:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T15:00:38Z.


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 6525 core/libs/prx/libkernel_sys/Export.cpp L306-335

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_sys/Export.cpp
PR 5528 core/libs/prx/libkernel_sys/Export.cpp
core/libs/tests/GuestKernelSys.cpp
PR 6044 core/libs/tests/GuestKernelSys.cpp
PR 7201 core/libs/prx/libkernel_sys/Export.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6293934518 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8522#issuecomment-6293934518). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-20T15:00:38Z. --- <!-- 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 6525](https://www.github.com/boykopovar/AnyPS5/pull/6525) | `core/libs/prx/libkernel_sys/Export.cpp` [L306-335](https://github.com/boykopovar/AnyPS5/blob/eb9f904d32ece402660286aed2cecf465094da07/core/libs/prx/libkernel_sys/Export.cpp#L306-L335) | | | 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_sys/Export.cpp` | | [PR 5528](https://www.github.com/boykopovar/AnyPS5/pull/5528) | `core/libs/prx/libkernel_sys/Export.cpp`<br>`core/libs/tests/GuestKernelSys.cpp` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/tests/GuestKernelSys.cpp` | | [PR 7201](https://www.github.com/boykopovar/AnyPS5/pull/7201) | `core/libs/prx/libkernel_sys/Export.cpp` |
adriadam10 commented 2026-10-21 18:48:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-21T18:48:10Z.


Checked the four not-found branches (pathconf, link source and destination parent, symlink parent, fchmodat chmod failure) against the existing HasNonDirectoryPrefix uses in the same file; the success paths are unchanged, and the new GuestKernelSys cases return 20 where main returned 2; merged.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6323868903 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8522#issuecomment-6323868903). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-21T18:48:10Z. --- Checked the four not-found branches (`pathconf`, `link` source and destination parent, `symlink` parent, `fchmodat` chmod failure) against the existing `HasNonDirectoryPrefix` uses in the same file; the success paths are unchanged, and the new `GuestKernelSys` cases return 20 where main returned 2; merged.
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!8522
No description provided.