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:
parent
f985673dc3
commit
8dbbbc1a1a
|
@ -55,5 +55,6 @@ namespace Kernel
|
|||
BAN::StringView get_early_boot_command_line(uint32_t magic, uint32_t info);
|
||||
|
||||
extern BootInfo g_boot_info;
|
||||
extern bool g_disable_disk_write;
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace Kernel
|
|||
{
|
||||
|
||||
BootInfo g_boot_info;
|
||||
bool g_disable_disk_write { false };
|
||||
|
||||
static MemoryMapEntry::Type bios_number_to_memory_type(uint32_t number)
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -85,6 +85,8 @@ static void parse_command_line()
|
|||
cmdline.disable_usb = true;
|
||||
else if (argument == "noacpi")
|
||||
cmdline.disable_acpi = true;
|
||||
else if (argument == "readonly")
|
||||
Kernel::g_disable_disk_write = true;
|
||||
else if (argument == "nodebug")
|
||||
g_disable_debug = true;
|
||||
else if (argument.starts_with("ps2="))
|
||||
|
|
Loading…
Reference in New Issue