mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-27 05:05:32 +03:00
Kernel/Ext2: Don't rely on block size 512 for superblock offset
This commit is contained in:
parent
10ba54a009
commit
bf1610d378
Notes:
sideshowbarker
2024-07-16 23:34:49 +09:00
Author: https://github.com/kleinesfilmroellchen Commit: https://github.com/SerenityOS/serenity/commit/bf1610d378 Pull-request: https://github.com/SerenityOS/serenity/pull/20086 Reviewed-by: https://github.com/gmta ✅
@ -29,12 +29,13 @@ Ext2FS::~Ext2FS() = default;
|
||||
ErrorOr<void> Ext2FS::flush_super_block()
|
||||
{
|
||||
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);
|
||||
auto const superblock_physical_block_count = (sizeof(ext2_super_block) / logical_block_size());
|
||||
|
||||
// FIXME: We currently have no ability of writing within a device block, but the ability to do so would allow us to use device block sizes larger than 1024.
|
||||
VERIFY((sizeof(ext2_super_block) % logical_block_size()) == 0);
|
||||
// First superblock is always at offset 1024 (physical block index 2).
|
||||
TRY(raw_write_blocks(2, superblock_physical_block_count, super_block_buffer));
|
||||
TRY(raw_write_blocks(1024 / logical_block_size(), superblock_physical_block_count, super_block_buffer));
|
||||
|
||||
auto is_sparse = has_flag(get_features_readonly(), FeaturesReadOnly::SparseSuperblock);
|
||||
|
||||
@ -71,7 +72,7 @@ ErrorOr<void> Ext2FS::initialize_while_locked()
|
||||
|
||||
VERIFY((sizeof(ext2_super_block) % logical_block_size()) == 0);
|
||||
auto super_block_buffer = UserOrKernelBuffer::for_kernel_buffer((u8*)&m_super_block);
|
||||
TRY(raw_read_blocks(2, (sizeof(ext2_super_block) / logical_block_size()), super_block_buffer));
|
||||
TRY(raw_read_blocks(1024 / logical_block_size(), (sizeof(ext2_super_block) / logical_block_size()), super_block_buffer));
|
||||
|
||||
auto const& super_block = this->super_block();
|
||||
if constexpr (EXT2_DEBUG) {
|
||||
|
Loading…
Reference in New Issue
Block a user