commit 3779c9fac818f0483217c2bf8114efa77a2e09eb
parent bff44508c89fab8bcef56e7ecc1db6b7452b58a4
Author: Sebastian <sebastian@sebsite.pw>
Date: Mon, 10 Oct 2022 17:26:42 -0400
rt: add fallocate and posix_fallocate
Implements: https://todo.sr.ht/~sircmpwn/hare/732
Signed-off-by: Sebastian <sebastian@sebsite.pw>
Diffstat:
2 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/rt/+freebsd/syscalls.ha b/rt/+freebsd/syscalls.ha
@@ -508,3 +508,8 @@ export fn dup2(oldfd: int, newfd: int) (int | errno) = {
export fn posix_openpt(flags: int) (int | errno) = {
return wrap_return(syscall1(SYS_posix_openpt, flags: u64))?: int;
};
+
+export fn posix_fallocate(fd: int, off: i64, ln: i64) (void | errno) = {
+ wrap_return(syscall3(SYS_posix_fallocate,
+ fd: u64, off: u64, ln: u64))?;
+};
diff --git a/rt/+linux/syscalls.ha b/rt/+linux/syscalls.ha
@@ -867,3 +867,12 @@ export fn tee(fd_in: int, fd_out: int, ln: size, flags: uint) (size | errno) = {
export fn alarm(seconds: uint) uint = {
return syscall1(SYS_alarm, seconds: u64): uint;
};
+
+export fn fallocate(fd: int, mode: int, off: i64, ln: i64) (void | errno) = {
+ wrap_return(syscall4(SYS_fallocate,
+ fd: u64, mode: u64, off: u64, ln: u64))?;
+};
+
+export fn posix_fallocate(fd: int, off: i64, ln: i64) (void | errno) = {
+ fallocate(fd, 0, off, ln)?;
+};