[libc-commits] [libc] [libc] Migrate filesystem syscall wrappers to syscall_checked (PR #225636)
Pavel Labath via libc-commits
libc-commits at lists.llvm.org
Wed Sep 23 06:31:11 PDT 2026
================
@@ -27,18 +27,15 @@ namespace linux_syscalls {
LIBC_INLINE ErrorOr<int> chmod(const char *path, mode_t mode) {
#ifdef SYS_fchmodat
- int ret = syscall_impl<int>(SYS_fchmodat, AT_FDCWD, path, mode, 0);
+ return syscall_checked<int>(SYS_fchmodat, AT_FDCWD, path, mode, 0);
#elif defined(SYS_fchmodat2)
- int ret = syscall_impl<int>(SYS_fchmodat2, AT_FDCWD, path, mode, 0,
+ return syscall_checked<int>(SYS_fchmodat2, AT_FDCWD, path, mode, 0,
AT_SYMLINK_NOFOLLOW);
----------------
labath wrote:
Good catch. This kind of works because the AT_SYMLINK_NOFOLLOW bug is cancelled out by another bug -- passing too many arguments to the syscall. fchmodat takes three arguments -- not four, which means the last zero is unused. and fchmodat2 takes four arguments -- not five, which means AT_SYMLINK_NOFOLLOW is ignored and zero is passed as flags.
That said, would you be okay, with keeping this as NFC as possible, and addressing the flags thing in a separate PR. I want to actually add a test to validate the behavior on symlinks.
https://github.com/llvm/llvm-project/pull/225636
More information about the libc-commits
mailing list