mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-28 21:54:40 +03:00
Kernel: Ensure we flush the entire ext2 superblock
This commit is contained in:
parent
061badeaea
commit
65dd9d5ad3
Notes:
sideshowbarker
2024-07-19 07:50:58 +09:00
Author: https://github.com/supercomputer7 Commit: https://github.com/SerenityOS/serenity/commit/65dd9d5ad30 Pull-request: https://github.com/SerenityOS/serenity/pull/1668
@ -81,7 +81,8 @@ Ext2FS::~Ext2FS()
|
||||
bool Ext2FS::flush_super_block()
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
bool success = raw_write(2, (const u8*)&m_super_block);
|
||||
ASSERT((sizeof(ext2_super_block) % logical_block_size()) == 0);
|
||||
bool success = raw_write_blocks(2, (sizeof(ext2_super_block) / logical_block_size()), (const u8*)&m_super_block);
|
||||
ASSERT(success);
|
||||
return true;
|
||||
}
|
||||
@ -96,7 +97,8 @@ const ext2_group_desc& Ext2FS::group_descriptor(GroupIndex group_index) const
|
||||
bool Ext2FS::initialize()
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
bool success = raw_read(2, (u8*)&m_super_block);
|
||||
ASSERT((sizeof(ext2_super_block) % logical_block_size()) == 0);
|
||||
bool success = raw_read_blocks(2, (sizeof(ext2_super_block) / logical_block_size()), (u8*)&m_super_block);
|
||||
ASSERT(success);
|
||||
|
||||
auto& super_block = this->super_block();
|
||||
|
@ -168,6 +168,25 @@ bool FileBackedFS::raw_write(unsigned index, const u8* buffer)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FileBackedFS::raw_read_blocks(unsigned index, size_t count, u8* buffer)
|
||||
{
|
||||
for (unsigned block = index; block < (index + count); block++) {
|
||||
if (!raw_read(block, buffer))
|
||||
return false;
|
||||
buffer += logical_block_size();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool FileBackedFS::raw_write_blocks(unsigned index, size_t count, const u8* buffer)
|
||||
{
|
||||
for (unsigned block = index; block < (index + count); block++) {
|
||||
if (!raw_write(block, buffer))
|
||||
return false;
|
||||
buffer += logical_block_size();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FileBackedFS::write_blocks(unsigned index, unsigned count, const u8* data, FileDescription* description)
|
||||
{
|
||||
ASSERT(m_logical_block_size);
|
||||
|
@ -58,6 +58,9 @@ protected:
|
||||
bool raw_read(unsigned index, u8* buffer);
|
||||
bool raw_write(unsigned index, const u8* buffer);
|
||||
|
||||
bool raw_read_blocks(unsigned index, size_t count, u8* buffer);
|
||||
bool raw_write_blocks(unsigned index, size_t count, const u8* buffer);
|
||||
|
||||
bool write_block(unsigned index, const u8*, FileDescription* = nullptr);
|
||||
bool write_blocks(unsigned index, unsigned count, const u8*, FileDescription* = nullptr);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user