[libc-commits] [libc] [libc] Add support for SYS_fchmodat2 in fchmodat (PR #223997)

Pavel Labath via libc-commits libc-commits at lists.llvm.org
Wed Sep 16 07:46:17 PDT 2026


================
@@ -24,8 +25,24 @@
 namespace LIBC_NAMESPACE_DECL {
 namespace linux_syscalls {
 
-LIBC_INLINE ErrorOr<int> fchmodat(int fd, const char *path, mode_t mode) {
+LIBC_INLINE ErrorOr<int> fchmodat(int fd, const char *path, mode_t mode,
+                                  int flags) {
+#ifdef SYS_fchmodat2
+  int ret = syscall_impl<int>(SYS_fchmodat2, fd, path, mode, flags);
+#if defined(SYS_fchmodat)
+  if (ret == -ENOSYS) {
+    if (flags != 0)
+      return Error(ENOTSUP);
+    ret = syscall_impl<int>(SYS_fchmodat, fd, path, mode);
+  }
+#endif
----------------
labath wrote:

I don't think we have fallbacks like this elsewhere (i.e. we generally assume that a SYS_whatever constant being defined means that the syscall is available). If you've seen this elsewhere, let me know. Otherwise, I'd just delete this.

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


More information about the libc-commits mailing list