Skip to content

Commit 230f332

Browse files
[libc] Swap order of syscall on chmod (#138427)
We define SYS_fchmodat2 on libc but the syscall is not available on old kernels, so prefer the SYS_fchmodat version when possible.
1 parent dfcb8cb commit 230f332

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

libc/src/sys/stat/linux/chmod.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ namespace LIBC_NAMESPACE_DECL {
2323
LLVM_LIBC_FUNCTION(int, chmod, (const char *path, mode_t mode)) {
2424
#ifdef SYS_chmod
2525
int ret = LIBC_NAMESPACE::syscall_impl<int>(SYS_chmod, path, mode);
26-
#elif defined(SYS_fchmodat2)
27-
int ret = LIBC_NAMESPACE::syscall_impl<int>(SYS_fchmodat2, AT_FDCWD, path,
28-
mode, 0, AT_SYMLINK_NOFOLLOW);
2926
#elif defined(SYS_fchmodat)
3027
int ret =
3128
LIBC_NAMESPACE::syscall_impl<int>(SYS_fchmodat, AT_FDCWD, path, mode, 0);
29+
#elif defined(SYS_fchmodat2)
30+
int ret = LIBC_NAMESPACE::syscall_impl<int>(SYS_fchmodat2, AT_FDCWD, path,
31+
mode, 0, AT_SYMLINK_NOFOLLOW);
3232
#else
3333
#error "chmod, fchmodat and fchmodat2 syscalls not available."
3434
#endif

0 commit comments

Comments
 (0)