[libc-commits] [libc] [libc] Migrate filesystem syscall wrappers to syscall_checked (PR #225636)

Jeff Bailey via libc-commits libc-commits at lists.llvm.org
Wed Sep 23 06:11:58 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);
----------------
kaladron wrote:

This looks like it will only issue AT_SYMLINK_NOFOLLOW on an archtiecture that is new enough to NOT have fchmodat.  If we need this behaviour, we should be doing it for the other two versionof the syscall too.

(And as a minor nit, we should probably be preferring at2 over at if it's present for least surprise when moving to newer platforms anyway, and we can drop the backup syscalls as our oldest supported version rolls forward)

https://github.com/llvm/llvm-project/pull/225636


More information about the libc-commits mailing list