summaryrefslogtreecommitdiff
path: root/Kernel/Syscalls/fallocate.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-11-27 20:13:15 +0100
committerAndreas Kling <kling@serenityos.org>2022-11-29 11:09:19 +0100
commit4277e2d58f1fc3f3600d36bf1cc71027374b8cf4 (patch)
treee1d53ba1ed34b397adf93009e9ed1853509aa840 /Kernel/Syscalls/fallocate.cpp
parent961e1e590b7c2d01effeda15fb10a064e6bfa8e7 (diff)
downloadserenity-4277e2d58f1fc3f3600d36bf1cc71027374b8cf4.zip
Kernel: Add some spec links and comments to sys$posix_fallocate()
Diffstat (limited to 'Kernel/Syscalls/fallocate.cpp')
-rw-r--r--Kernel/Syscalls/fallocate.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/Kernel/Syscalls/fallocate.cpp b/Kernel/Syscalls/fallocate.cpp
index 18269c061d..8f924219ed 100644
--- a/Kernel/Syscalls/fallocate.cpp
+++ b/Kernel/Syscalls/fallocate.cpp
@@ -12,11 +12,13 @@
namespace Kernel {
+// https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_fallocate.html
ErrorOr<FlatPtr> Process::sys$posix_fallocate(int fd, Userspace<off_t const*> userspace_offset, Userspace<off_t const*> userspace_length)
{
VERIFY_NO_PROCESS_BIG_LOCK(this);
TRY(require_promise(Pledge::stdio));
+ // [EINVAL] The len argument is less than zero, or the offset argument is less than zero, or the underlying file system does not support this operation.
auto offset = TRY(copy_typed_from_user(userspace_offset));
if (offset < 0)
return EINVAL;
@@ -31,9 +33,12 @@ ErrorOr<FlatPtr> Process::sys$posix_fallocate(int fd, Userspace<off_t const*> us
return EFBIG;
auto description = TRY(open_file_description(fd));
+
+ // [EBADF] The fd argument references a file that was opened without write permission.
if (!description->is_writable())
return EBADF;
+ // [ESPIPE] The fd argument is associated with a pipe or FIFO.
if (description->is_fifo())
return ESPIPE;