[libc-commits] [libc] 4182120 - [libc] adding linux SYS_fchmodat2 syscall. (#89819)
via libc-commits
libc-commits at lists.llvm.org
Tue Apr 23 14:58:04 PDT 2024
Author: David CARLIER
Date: 2024-04-23T22:58:00+01:00
New Revision: 418212089e95e2d39d2997699a149a09d4c5185c
URL: https://github.com/llvm/llvm-project/commit/418212089e95e2d39d2997699a149a09d4c5185c
DIFF: https://github.com/llvm/llvm-project/commit/418212089e95e2d39d2997699a149a09d4c5185c.diff
LOG: [libc] adding linux SYS_fchmodat2 syscall. (#89819)
Added:
Modified:
libc/config/linux/syscall_numbers.h.inc
libc/src/sys/stat/linux/chmod.cpp
Removed:
################################################################################
diff --git a/libc/config/linux/syscall_numbers.h.inc b/libc/config/linux/syscall_numbers.h.inc
index 9f910c5f9042a8..4a19d9a08875e8 100644
--- a/libc/config/linux/syscall_numbers.h.inc
+++ b/libc/config/linux/syscall_numbers.h.inc
@@ -338,6 +338,10 @@
#define SYS_fchmodat __NR_fchmodat
#endif
+#ifdef __NR_fchmodat2
+#define SYS_fchmodat2 __NR_fchmodat2
+#endif
+
#ifdef __NR_fchown
#define SYS_fchown __NR_fchown
#endif
diff --git a/libc/src/sys/stat/linux/chmod.cpp b/libc/src/sys/stat/linux/chmod.cpp
index 085b91691d89f4..25e5e69af71a08 100644
--- a/libc/src/sys/stat/linux/chmod.cpp
+++ b/libc/src/sys/stat/linux/chmod.cpp
@@ -21,11 +21,14 @@ namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(int, chmod, (const char *path, mode_t mode)) {
#ifdef SYS_chmod
int ret = LIBC_NAMESPACE::syscall_impl<int>(SYS_chmod, path, mode);
+#elif defined(SYS_fchmodat2)
+ int ret = LIBC_NAMESPACE::syscall_impl<int>(SYS_fchmodat2, AT_FDCWD, path,
+ mode, 0, AT_SYMLINK_NOFOLLOW);
#elif defined(SYS_fchmodat)
int ret =
- LIBC_NAMESPACE::syscall_impl<int>(SYS_fchmodat, AT_FDCWD, path, mode);
+ LIBC_NAMESPACE::syscall_impl<int>(SYS_fchmodat, AT_FDCWD, path, mode, 0);
#else
-#error "chmod and fchmodat syscalls not available."
+#error "chmod, fchmodat and fchmodat2 syscalls not available."
#endif
if (ret < 0) {
More information about the libc-commits
mailing list