Skip to content

Commit

Permalink
[libc] adding linux SYS_fchmodat2 syscall. (#89819)
Browse files Browse the repository at this point in the history
  • Loading branch information
devnexen committed Apr 23, 2024
1 parent ef59069 commit 4182120
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions libc/config/linux/syscall_numbers.h.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions libc/src/sys/stat/linux/chmod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 4182120

Please sign in to comment.