summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem/InodeFile.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-08-04 18:02:23 +0200
committerAndreas Kling <kling@serenityos.org>2020-08-04 18:17:16 +0200
commit7a3ab6c517649e9dfdd50085f10492212b0bcb18 (patch)
treef251cfc69ebe5f253c1e900c10b9485136b315cd /Kernel/FileSystem/InodeFile.cpp
parent58feebeed28bab04e7b462f7cd3beb81984f116e (diff)
downloadserenity-7a3ab6c517649e9dfdd50085f10492212b0bcb18.zip
Kernel: Make File::write() and File::read() return KResultOr<size_t>
Instead of returning a ssize_t where negative values mean error, we now return KResultOr<size_t> and use the error state to report errors exclusively.
Diffstat (limited to 'Kernel/FileSystem/InodeFile.cpp')
-rw-r--r--Kernel/FileSystem/InodeFile.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/Kernel/FileSystem/InodeFile.cpp b/Kernel/FileSystem/InodeFile.cpp
index 6bbb9e5873..c2657fe969 100644
--- a/Kernel/FileSystem/InodeFile.cpp
+++ b/Kernel/FileSystem/InodeFile.cpp
@@ -44,21 +44,25 @@ InodeFile::~InodeFile()
{
}
-ssize_t InodeFile::read(FileDescription& description, size_t offset, u8* buffer, ssize_t count)
+KResultOr<size_t> InodeFile::read(FileDescription& description, size_t offset, u8* buffer, size_t count)
{
ssize_t nread = m_inode->read_bytes(offset, count, buffer, &description);
if (nread > 0)
Thread::current()->did_file_read(nread);
+ if (nread < 0)
+ return KResult(nread);
return nread;
}
-ssize_t InodeFile::write(FileDescription& description, size_t offset, const u8* data, ssize_t count)
+KResultOr<size_t> InodeFile::write(FileDescription& description, size_t offset, const u8* data, size_t count)
{
ssize_t nwritten = m_inode->write_bytes(offset, count, data, &description);
if (nwritten > 0) {
m_inode->set_mtime(kgettimeofday().tv_sec);
Thread::current()->did_file_write(nwritten);
}
+ if (nwritten < 0)
+ return KResult(nwritten);
return nwritten;
}