From c8ff2184bdbcded12785cc82585c6d5a80af42f9 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 27 Nov 2022 19:46:03 +0100 Subject: [PATCH] LibCore: Add Core::System::posix_fallocate() --- Userland/Libraries/LibCore/System.cpp | 10 ++++++++++ Userland/Libraries/LibCore/System.h | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/Userland/Libraries/LibCore/System.cpp b/Userland/Libraries/LibCore/System.cpp index 3c1ab3264b..3239f3e4d6 100644 --- a/Userland/Libraries/LibCore/System.cpp +++ b/Userland/Libraries/LibCore/System.cpp @@ -1400,4 +1400,14 @@ ErrorOr readlink(StringView pathname) #endif } +#ifdef AK_OS_SERENITY +ErrorOr posix_fallocate(int fd, off_t offset, off_t length) +{ + int rc = ::posix_fallocate(fd, offset, length); + if (rc != 0) + return Error::from_syscall("posix_fallocate"sv, -rc); + return {}; +} +#endif + } diff --git a/Userland/Libraries/LibCore/System.h b/Userland/Libraries/LibCore/System.h index e0f49b0982..5b1e9f4abb 100644 --- a/Userland/Libraries/LibCore/System.h +++ b/Userland/Libraries/LibCore/System.h @@ -206,4 +206,8 @@ ErrorOr unlockpt(int fildes); ErrorOr access(StringView pathname, int mode); ErrorOr readlink(StringView pathname); +#ifdef AK_OS_SERENITY +ErrorOr posix_fallocate(int fd, off_t offset, off_t length); +#endif + }