Skip to content

Commit 4182120

Browse files
authored
[libc] adding linux SYS_fchmodat2 syscall. (llvm#89819)
1 parent ef59069 commit 4182120

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

libc/config/linux/syscall_numbers.h.inc

+4
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,10 @@
338338
#define SYS_fchmodat __NR_fchmodat
339339
#endif
340340

341+
#ifdef __NR_fchmodat2
342+
#define SYS_fchmodat2 __NR_fchmodat2
343+
#endif
344+
341345
#ifdef __NR_fchown
342346
#define SYS_fchown __NR_fchown
343347
#endif

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

+5-2
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,14 @@ namespace LIBC_NAMESPACE {
2121
LLVM_LIBC_FUNCTION(int, chmod, (const char *path, mode_t mode)) {
2222
#ifdef SYS_chmod
2323
int ret = LIBC_NAMESPACE::syscall_impl<int>(SYS_chmod, path, mode);
24+
#elif defined(SYS_fchmodat2)
25+
int ret = LIBC_NAMESPACE::syscall_impl<int>(SYS_fchmodat2, AT_FDCWD, path,
26+
mode, 0, AT_SYMLINK_NOFOLLOW);
2427
#elif defined(SYS_fchmodat)
2528
int ret =
26-
LIBC_NAMESPACE::syscall_impl<int>(SYS_fchmodat, AT_FDCWD, path, mode);
29+
LIBC_NAMESPACE::syscall_impl<int>(SYS_fchmodat, AT_FDCWD, path, mode, 0);
2730
#else
28-
#error "chmod and fchmodat syscalls not available."
31+
#error "chmod, fchmodat and fchmodat2 syscalls not available."
2932
#endif
3033

3134
if (ret < 0) {

0 commit comments

Comments
 (0)