mirror of
https://github.com/RGBCube/serenity
synced 2025-05-15 04:24:59 +00:00
Kernel: Handle OOM in DiskCache when mounting Ext2 filesystems
Create the disk cache up front, so we can verify it succeeds. Make the KBuffer allocation fail-able, so we can properly handle failure when the user asks up to mount a Ext2 filesystem under OOM conditions.
This commit is contained in:
parent
187c086270
commit
a6db2f985a
3 changed files with 36 additions and 12 deletions
|
@ -89,6 +89,7 @@ const ext2_group_desc& Ext2FS::group_descriptor(GroupIndex group_index) const
|
|||
bool Ext2FS::initialize()
|
||||
{
|
||||
MutexLocker locker(m_lock);
|
||||
|
||||
VERIFY((sizeof(ext2_super_block) % logical_block_size()) == 0);
|
||||
auto super_block_buffer = UserOrKernelBuffer::for_kernel_buffer((u8*)&m_super_block);
|
||||
bool success = raw_read_blocks(2, (sizeof(ext2_super_block) / logical_block_size()), super_block_buffer);
|
||||
|
@ -115,6 +116,11 @@ bool Ext2FS::initialize()
|
|||
set_block_size(EXT2_BLOCK_SIZE(&super_block));
|
||||
set_fragment_size(EXT2_FRAG_SIZE(&super_block));
|
||||
|
||||
// Note: This depends on the block size being available.
|
||||
auto baseclass_result = BlockBasedFileSystem::initialize();
|
||||
if (!baseclass_result)
|
||||
return baseclass_result;
|
||||
|
||||
VERIFY(block_size() <= (int)max_block_size);
|
||||
|
||||
m_block_group_count = ceil_div(super_block.s_blocks_count, super_block.s_blocks_per_group);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue