From 0b2e93cf43f98b2b9826b12c193f8152178c39a7 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Tue, 25 Jan 2022 20:23:53 +0200 Subject: [PATCH] Kernel: Use u64 instead of size_t for BlockBasedFileSystem::write_block This ensures offsets will not be truncated on large filesystems on i686 --- Kernel/FileSystem/BlockBasedFileSystem.cpp | 4 ++-- Kernel/FileSystem/BlockBasedFileSystem.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Kernel/FileSystem/BlockBasedFileSystem.cpp b/Kernel/FileSystem/BlockBasedFileSystem.cpp index 489f534439..6361c90178 100644 --- a/Kernel/FileSystem/BlockBasedFileSystem.cpp +++ b/Kernel/FileSystem/BlockBasedFileSystem.cpp @@ -131,7 +131,7 @@ ErrorOr BlockBasedFileSystem::initialize() return {}; } -ErrorOr BlockBasedFileSystem::write_block(BlockIndex index, const UserOrKernelBuffer& data, size_t count, size_t offset, bool allow_cache) +ErrorOr BlockBasedFileSystem::write_block(BlockIndex index, const UserOrKernelBuffer& data, size_t count, u64 offset, bool allow_cache) { VERIFY(m_logical_block_size); VERIFY(offset + count <= block_size()); @@ -147,7 +147,7 @@ ErrorOr BlockBasedFileSystem::write_block(BlockIndex index, const UserOrKe return m_cache.with_exclusive([&](auto& cache) -> ErrorOr { if (!allow_cache) { flush_specific_block_if_needed(index); - auto base_offset = index.value() * block_size() + offset; + u64 base_offset = index.value() * block_size() + offset; auto nwritten = TRY(file_description().write(base_offset, data, count)); VERIFY(nwritten == count); return {}; diff --git a/Kernel/FileSystem/BlockBasedFileSystem.h b/Kernel/FileSystem/BlockBasedFileSystem.h index f1cfa29818..2355aba79b 100644 --- a/Kernel/FileSystem/BlockBasedFileSystem.h +++ b/Kernel/FileSystem/BlockBasedFileSystem.h @@ -35,7 +35,7 @@ protected: ErrorOr raw_read_blocks(BlockIndex index, size_t count, UserOrKernelBuffer&); ErrorOr raw_write_blocks(BlockIndex index, size_t count, const UserOrKernelBuffer&); - ErrorOr write_block(BlockIndex, const UserOrKernelBuffer&, size_t count, size_t offset = 0, bool allow_cache = true); + ErrorOr write_block(BlockIndex, const UserOrKernelBuffer&, size_t count, u64 offset = 0, bool allow_cache = true); ErrorOr write_blocks(BlockIndex, unsigned count, const UserOrKernelBuffer&, bool allow_cache = true); u64 m_logical_block_size { 512 };