libkernel_sys: fchmodat silently succeeds on a symbolic link where lchmod throws #14088

Closed
opened 2026-10-31 18:36:41 +00:00 by LeandroLP23 · 0 comments
LeandroLP23 commented 2026-10-31 18:36:41 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-31T18:36:41Z.


What happens

fchmodat and lchmod treat the same request differently on Windows and Linux: changing the mode of a symbolic link itself, which those hosts cannot do.

  • fchmodat(fd, path, mode, AT_SYMLINK_NOFOLLOW) on a symbolic link returns 0 and changes nothing (core/libs/prx/libkernel_sys/Export.cpp, the GuestAtSymlinkNofollow branch at line 964; only macOS calls the host fchmodat there).
  • lchmod(path, mode) on the same link throws NotImplemented_nid_no_patch("lchmod: the mode of a symbolic link on a host that cannot change it") (line 1001), and only then forwards to fchmodat(AT_FDCWD, path, mode, AT_SYMLINK_NOFOLLOW), as FreeBSD's sys_lchmod does.

Both are documented in docs/dev/debt/libkernel_sys.md: fchmodat is listed under Silent stubs (line 5) and in the entry at line 353, and lchmod's throw is at line 354. So the same unsupported operation is a fabricated success through one entry point and a throw through the other.

Proposal

Make fchmodat throw in that branch on Windows and Linux, like lchmod, and drop lchmod's own symlink check and the Silent stubs entry. lchmod would then reach the throw through fchmodat. This follows the project rule that a path either does what it should or throws.

Question for maintainers

Was the silent success in fchmodat kept on purpose, for example because a title calls fchmodat(..., AT_SYMLINK_NOFOLLOW) on links during installation or save handling and must not stop there? If so, should lchmod return 0 too, for consistency? If not, I can open the PR that makes both throw.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:6138395671 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/14088). Originally posted by [LeandroLP23](https://github.com/LeandroLP23) on 2026-10-31T18:36:41Z. --- ### What happens `fchmodat` and `lchmod` treat the same request differently on Windows and Linux: changing the mode of a symbolic link itself, which those hosts cannot do. - `fchmodat(fd, path, mode, AT_SYMLINK_NOFOLLOW)` on a symbolic link returns 0 and changes nothing (`core/libs/prx/libkernel_sys/Export.cpp`, the `GuestAtSymlinkNofollow` branch at line 964; only macOS calls the host `fchmodat` there). - `lchmod(path, mode)` on the same link throws `NotImplemented_nid_no_patch("lchmod: the mode of a symbolic link on a host that cannot change it")` (line 1001), and only then forwards to `fchmodat(AT_FDCWD, path, mode, AT_SYMLINK_NOFOLLOW)`, as FreeBSD's `sys_lchmod` does. Both are documented in `docs/dev/debt/libkernel_sys.md`: `fchmodat` is listed under **Silent stubs** (line 5) and in the entry at line 353, and `lchmod`'s throw is at line 354. So the same unsupported operation is a fabricated success through one entry point and a throw through the other. ### Proposal Make `fchmodat` throw in that branch on Windows and Linux, like `lchmod`, and drop `lchmod`'s own symlink check and the Silent stubs entry. `lchmod` would then reach the throw through `fchmodat`. This follows the project rule that a path either does what it should or throws. ### Question for maintainers Was the silent success in `fchmodat` kept on purpose, for example because a title calls `fchmodat(..., AT_SYMLINK_NOFOLLOW)` on links during installation or save handling and must not stop there? If so, should `lchmod` return 0 too, for consistency? If not, I can open the PR that makes both throw. AI-assisted: yes (Claude Code)
Sign in to join this conversation.
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#14088
No description provided.