commit 546d15baeed597c3d73894af5845ceb5ee1d6812
parent 4e7dd2a1e52188e04ab672bb42566fecfec448c1
Author: Curtis Arthaud <uku82@gmx.fr>
Date: Sun, 7 Apr 2024 09:57:41 +0200
syscalls: add fchmod, fchown
Signed-off-by: Curtis Arthaud <uku82@gmx.fr>
Diffstat:
3 files changed, 48 insertions(+), 0 deletions(-)
diff --git a/rt/+freebsd/syscalls.ha b/rt/+freebsd/syscalls.ha
@@ -191,12 +191,23 @@ export fn mkdirat(dirfd: int, path: path, mode: uint) (void | errno) = {
dirfd: u64, path: uintptr: u64, mode: u64))?;
};
+
+export fn fchmod(fd: int, mode: uint) (void | errno) = {
+ wrap_return(syscall2(SYS_fchmod,
+ fd: u64, mode: u64))?;
+};
+
export fn fchmodat(dirfd: int, path: path, mode: uint, flags: int) (void | errno) = {
let path = kpath(path)?;
wrap_return(syscall4(SYS_fchmodat,
dirfd: u64, path: uintptr: u64, mode: u64, flags: u64))?;
};
+export fn fchown(fd: int, uid: uint, gid: uint) (void | errno) = {
+ wrap_return(syscall3(SYS_fchown,
+ fd: u64, uid: u32, gid: u32))?;
+};
+
export fn fchownat(dirfd: int, path: path, uid: uint, gid: uint, flags: int) (void | errno) = {
let path = kpath(path)?;
wrap_return(syscall5(SYS_fchownat,
diff --git a/rt/+linux/syscalls.ha b/rt/+linux/syscalls.ha
@@ -159,6 +159,11 @@ export fn chmod(path: path, mode: uint) (void | errno) = {
AT_FDCWD: u64, path: uintptr: u64, mode: u64, 0))?;
};
+export fn fchmod(fd: int, mode: uint) (void | errno) = {
+ wrap_return(syscall2(SYS_fchmod,
+ fd: u64, mode: u64))?;
+};
+
export fn fchmodat(dirfd: int, path: path, mode: uint, flags: int) (void | errno) = {
let path = kpath(path)?;
wrap_return(syscall4(SYS_fchmodat,
@@ -171,6 +176,11 @@ export fn chown(path: path, uid: uint, gid: uint) (void | errno) = {
AT_FDCWD: u64, path: uintptr: u64, uid: u32, gid: u32, 0))?;
};
+export fn fchown(fd: int, uid: uint, gid: uint) (void | errno) = {
+ wrap_return(syscall3(SYS_fchown,
+ fd: u64, uid: u32, gid: u32))?;
+};
+
export fn fchownat(dirfd: int, path: path, uid: uint, gid: uint, flags: int) (void | errno) = {
let path = kpath(path)?;
wrap_return(syscall5(SYS_fchownat,
diff --git a/rt/+openbsd/syscalls.ha b/rt/+openbsd/syscalls.ha
@@ -994,7 +994,34 @@ export fn kill(pid: int, signal: int) (void | errno) = {
};
// fchown
+
+@symbol("fchown") fn libc_fchown(
+ fd: int,
+ owner: uid_t,
+ group: gid_t
+) int;
+
+export fn fchown(fd: int, uid: uid_t, gid: gid_t) (void | errno) = {
+ let res = libc_fchown(fd, uid, gid);
+ if (res == -1) {
+ return *__errno(): errno;
+ };
+};
+
// fchmod
+
+@symbol("fchmod") fn libc_fchmod(
+ fd: int,
+ mode: uint
+) int;
+
+export fn fchmod(fd: int, mode: uint) (void | errno) = {
+ let res = libc_fchmod(fd, mode);
+ if (res == -1) {
+ return *__errno(): errno;
+ };
+};
+
// setreuid
// setregid
// rename