From 773747cf9ccd8ba7ac3dcc8363284e11983b6630 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Mon, 10 Jul 2023 15:11:27 +0300 Subject: [PATCH] Kernel: O_APPEND is now supported --- kernel/kernel/OpenFileDescriptorSet.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/kernel/OpenFileDescriptorSet.cpp b/kernel/kernel/OpenFileDescriptorSet.cpp index 56e399c4d6..67fd255b34 100644 --- a/kernel/kernel/OpenFileDescriptorSet.cpp +++ b/kernel/kernel/OpenFileDescriptorSet.cpp @@ -49,7 +49,7 @@ namespace Kernel BAN::ErrorOr OpenFileDescriptorSet::open(BAN::StringView absolute_path, int flags) { - if (flags & ~(O_RDONLY | O_WRONLY | O_NOFOLLOW | O_SEARCH | O_CLOEXEC)) + if (flags & ~(O_RDONLY | O_WRONLY | O_NOFOLLOW | O_SEARCH | O_APPEND | O_CLOEXEC)) return BAN::Error::from_errno(ENOTSUP); auto file = TRY(VirtualFileSystem::get().file_from_absolute_path(m_credentials, absolute_path, flags)); @@ -190,6 +190,8 @@ namespace Kernel { TRY(validate_fd(fd)); auto& open_file = m_open_files[fd]; + if (open_file->flags & O_APPEND) + open_file->offset = open_file->inode->size(); size_t nwrite = TRY(open_file->inode->write(open_file->offset, buffer, count)); open_file->offset += nwrite; return nwrite;