Skip to content

[libc] adding linux SYS_fchmodat2 syscall. #89819

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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