summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorHendiadyoin1 <leon.a@serenityos.org>2022-06-18 18:37:54 +0200
committerAndreas Kling <kling@serenityos.org>2022-07-15 12:42:43 +0200
commitd783389877435ef937b4306ac689470a5ca576bb (patch)
tree843854df4a14ace514d1f4e803e3e3a582bab5bb /Userland/Libraries
parentad904cdcab84bc2afe0c648ca126f12a781dbf5f (diff)
downloadserenity-d783389877435ef937b4306ac689470a5ca576bb.zip
Kernel+LibC: Add posix_fallocate syscall
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibC/fcntl.cpp7
-rw-r--r--Userland/Libraries/LibC/fcntl.h1
2 files changed, 8 insertions, 0 deletions
diff --git a/Userland/Libraries/LibC/fcntl.cpp b/Userland/Libraries/LibC/fcntl.cpp
index e67a82d357..97fe440606 100644
--- a/Userland/Libraries/LibC/fcntl.cpp
+++ b/Userland/Libraries/LibC/fcntl.cpp
@@ -104,6 +104,13 @@ int posix_fadvise(int fd, off_t offset, off_t len, int advice)
return 0;
}
+// https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_fallocate.html
+int posix_fallocate(int fd, off_t offset, off_t len)
+{
+ // posix_fallocate does not set errno.
+ return static_cast<int>(syscall(SC_posix_fallocate, fd, &offset, &len));
+}
+
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/utimensat.html
int utimensat(int dirfd, char const* path, struct timespec const times[2], int flag)
{
diff --git a/Userland/Libraries/LibC/fcntl.h b/Userland/Libraries/LibC/fcntl.h
index 3704d6a7a7..bf640c79f5 100644
--- a/Userland/Libraries/LibC/fcntl.h
+++ b/Userland/Libraries/LibC/fcntl.h
@@ -29,6 +29,7 @@ int inode_watcher_add_watch(int fd, char const* path, size_t path_length, unsign
int inode_watcher_remove_watch(int fd, int wd);
int posix_fadvise(int fd, off_t offset, off_t len, int advice);
+int posix_fallocate(int fd, off_t offset, off_t len);
int utimensat(int dirfd, char const* path, struct timespec const times[2], int flag);