summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem/FileDescription.cpp
diff options
context:
space:
mode:
authorasynts <asynts@gmail.com>2020-09-15 12:24:14 +0200
committerAndreas Kling <kling@serenityos.org>2020-09-15 20:36:45 +0200
commit206dcd84a6f5e8a7a2713bb05925b2c571611689 (patch)
tree71c5160defcdf0102999352033936acaf24014c7 /Kernel/FileSystem/FileDescription.cpp
parentc8ed882b8ec4501c64ccbd74f5c215710c66371e (diff)
downloadserenity-206dcd84a6f5e8a7a2713bb05925b2c571611689.zip
FileSystem: Use OutputMemoryStream instead of BufferStream.
Diffstat (limited to 'Kernel/FileSystem/FileDescription.cpp')
-rw-r--r--Kernel/FileSystem/FileDescription.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/Kernel/FileSystem/FileDescription.cpp b/Kernel/FileSystem/FileDescription.cpp
index 8c88dfc816..a361e1d046 100644
--- a/Kernel/FileSystem/FileDescription.cpp
+++ b/Kernel/FileSystem/FileDescription.cpp
@@ -24,7 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <AK/BufferStream.h>
+#include <AK/MemoryStream.h>
#include <Kernel/Devices/BlockDevice.h>
#include <Kernel/Devices/CharacterDevice.h>
#include <Kernel/FileSystem/Custody.h>
@@ -178,26 +178,26 @@ ssize_t FileDescription::get_dir_entries(UserOrKernelBuffer& buffer, ssize_t siz
size_t size_to_allocate = max(static_cast<size_t>(PAGE_SIZE), static_cast<size_t>(metadata.size));
auto temp_buffer = ByteBuffer::create_uninitialized(size_to_allocate);
- BufferStream stream(temp_buffer);
+ OutputMemoryStream stream { temp_buffer };
+
KResult result = VFS::the().traverse_directory_inode(*m_inode, [&stream, this](auto& entry) {
stream << (u32)entry.inode.index();
stream << m_inode->fs().internal_file_type_to_directory_entry_type(entry);
stream << (u32)entry.name.length();
- stream << entry.name;
+ stream << entry.name.bytes();
return true;
});
if (result.is_error())
return result;
- stream.snip();
-
- if (static_cast<size_t>(size) < temp_buffer.size())
+ if (static_cast<size_t>(size) < stream.size())
return -EINVAL;
- if (!buffer.write(temp_buffer.data(), temp_buffer.size()))
+ if (!buffer.write(stream.bytes()))
return -EFAULT;
- return stream.offset();
+
+ return stream.size();
}
bool FileDescription::is_device() const