libkernel_sys: fchmodat silently succeeds on a symbolic link where lchmod throws #14088
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 LeandroLP23 on 2026-10-31T18:36:41Z.
What happens
fchmodatandlchmodtreat 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, theGuestAtSymlinkNofollowbranch at line 964; only macOS calls the hostfchmodatthere).lchmod(path, mode)on the same link throwsNotImplemented_nid_no_patch("lchmod: the mode of a symbolic link on a host that cannot change it")(line 1001), and only then forwards tofchmodat(AT_FDCWD, path, mode, AT_SYMLINK_NOFOLLOW), as FreeBSD'ssys_lchmoddoes.Both are documented in
docs/dev/debt/libkernel_sys.md:fchmodatis listed under Silent stubs (line 5) and in the entry at line 353, andlchmod'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
fchmodatthrow in that branch on Windows and Linux, likelchmod, and droplchmod's own symlink check and the Silent stubs entry.lchmodwould then reach the throw throughfchmodat. This follows the project rule that a path either does what it should or throws.Question for maintainers
Was the silent success in
fchmodatkept on purpose, for example because a title callsfchmodat(..., AT_SYMLINK_NOFOLLOW)on links during installation or save handling and must not stop there? If so, shouldlchmodreturn 0 too, for consistency? If not, I can open the PR that makes both throw.AI-assisted: yes (Claude Code)