Kernel: Add command line option readonly

This prevents calls to write_sectors_impl and all dirty pages are always
kept in RAM.
This commit is contained in:
2024-11-27 13:31:55 +02:00
parent f985673dc3
commit 8dbbbc1a1a
5 changed files with 16 additions and 0 deletions

View File

@@ -1,3 +1,4 @@
#include <kernel/BootInfo.h>
#include <kernel/Lock/LockGuard.h>
#include <kernel/Memory/Heap.h>
#include <kernel/Memory/PageTable.h>
@@ -105,6 +106,9 @@ namespace Kernel
BAN::ErrorOr<void> DiskCache::sync()
{
if (g_disable_disk_write)
return {};
for (auto& cache : m_cache)
{
if (cache.dirty_mask == 0)

View File

@@ -2,6 +2,7 @@
#include <BAN/ScopeGuard.h>
#include <BAN/StringView.h>
#include <BAN/UTF8.h>
#include <kernel/BootInfo.h>
#include <kernel/FS/DevFS/FileSystem.h>
#include <kernel/FS/VirtualFileSystem.h>
#include <kernel/Lock/LockGuard.h>
@@ -265,6 +266,13 @@ namespace Kernel
LockGuard _(m_mutex);
if (g_disable_disk_write)
{
if (!m_disk_cache.has_value())
return BAN::Error::from_errno(EIO);
return m_disk_cache->write_to_cache(lba, buffer, true);
}
if (!m_disk_cache.has_value())
return write_sectors_impl(lba, sector_count, buffer);