From 03b5c8e76e59a257f26a1c14337b77384c50ea35 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Thu, 16 Jan 2025 16:16:38 +0200 Subject: [PATCH] Kernel: Fix disk caching when `readonly` is specified --- kernel/kernel/Storage/StorageDevice.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/kernel/Storage/StorageDevice.cpp b/kernel/kernel/Storage/StorageDevice.cpp index d7da86e2..c183dbaf 100644 --- a/kernel/kernel/Storage/StorageDevice.cpp +++ b/kernel/kernel/Storage/StorageDevice.cpp @@ -270,7 +270,9 @@ namespace Kernel { if (!m_disk_cache.has_value()) return BAN::Error::from_errno(EIO); - return m_disk_cache->write_to_cache(lba, buffer, true); + for (size_t i = 0; i < sector_count; i++) + TRY(m_disk_cache->write_to_cache(lba + i, buffer.slice(i * sector_size(), sector_size()), true)); + return {}; } if (!m_disk_cache.has_value())