summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-07-17 22:11:41 +0200
committerAndreas Kling <kling@serenityos.org>2021-07-17 22:11:41 +0200
commit0d89cfcd9a4ef7c0d5aa283747e09bbe392e61b7 (patch)
treef0271bef398388e6c076c207477ec0cd83bbfb1c
parentcd4d73e19eeabbf97a402dc0fd8d271a99424989 (diff)
downloadserenity-0d89cfcd9a4ef7c0d5aa283747e09bbe392e61b7.zip
Kernel/DevFS: Use KString for DevFSLinkInode::m_link
-rw-r--r--Kernel/FileSystem/DevFS.cpp14
-rw-r--r--Kernel/FileSystem/DevFS.h2
2 files changed, 10 insertions, 6 deletions
diff --git a/Kernel/FileSystem/DevFS.cpp b/Kernel/FileSystem/DevFS.cpp
index 94bb95e72c..4321f92218 100644
--- a/Kernel/FileSystem/DevFS.cpp
+++ b/Kernel/FileSystem/DevFS.cpp
@@ -158,10 +158,10 @@ KResultOr<size_t> DevFSLinkInode::read_bytes(off_t offset, size_t, UserOrKernelB
{
Locker locker(m_inode_lock);
VERIFY(offset == 0);
- VERIFY(!m_link.is_null());
- if (!buffer.write(((const u8*)m_link.substring_view(0).characters_without_null_termination()) + offset, m_link.length()))
+ VERIFY(m_link);
+ if (!buffer.write(m_link->characters() + offset, m_link->length()))
return EFAULT;
- return m_link.length();
+ return m_link->length();
}
InodeMetadata DevFSLinkInode::metadata() const
@@ -176,12 +176,16 @@ InodeMetadata DevFSLinkInode::metadata() const
return metadata;
}
-KResultOr<size_t> DevFSLinkInode::write_bytes(off_t offset, size_t count, const UserOrKernelBuffer& buffer, FileDescription*)
+KResultOr<size_t> DevFSLinkInode::write_bytes(off_t offset, size_t count, UserOrKernelBuffer const& buffer, FileDescription*)
{
+ auto kstring_or_error = buffer.try_copy_into_kstring(count);
+ if (kstring_or_error.is_error())
+ return kstring_or_error.error();
+
Locker locker(m_inode_lock);
VERIFY(offset == 0);
VERIFY(buffer.is_kernel_buffer());
- m_link = buffer.copy_into_string(count);
+ m_link = kstring_or_error.release_value();
return count;
}
diff --git a/Kernel/FileSystem/DevFS.h b/Kernel/FileSystem/DevFS.h
index fed150869c..a0782f6ac9 100644
--- a/Kernel/FileSystem/DevFS.h
+++ b/Kernel/FileSystem/DevFS.h
@@ -104,7 +104,7 @@ protected:
virtual KResultOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer& buffer, FileDescription*) override;
NonnullOwnPtr<KString> m_name;
- String m_link;
+ OwnPtr<KString> m_link;
};
class DevFSDirectoryInode : public DevFSInode {