mirror of
https://github.com/SerenityOS/serenity
synced 2026-05-09 00:22:43 +02:00
Kernel/Ext2FS: Replace hardcoded offset with a constexpr
The superblock of an ext2 filesystem is always found on the storage device at offset 1024. This 1024 number was hardcoded in the Ext2FS code. This commit: * adds a constexpr to replace the hardcoded 1024 values * removes a comment about one of the the hardcoded 1024 values which is now umnecessary
This commit is contained in:
@@ -34,8 +34,7 @@ ErrorOr<void> Ext2FS::flush_super_block()
|
||||
|
||||
// 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) % device_block_size()) == 0);
|
||||
// First superblock is always at offset 1024 (physical block index 2).
|
||||
TRY(raw_write_blocks(1024 / device_block_size(), superblock_physical_block_count, super_block_buffer));
|
||||
TRY(raw_write_blocks(super_block_offset_on_device / device_block_size(), superblock_physical_block_count, super_block_buffer));
|
||||
|
||||
auto is_sparse = has_flag(get_features_readonly(), FeaturesReadOnly::SparseSuperblock);
|
||||
|
||||
@@ -72,7 +71,7 @@ ErrorOr<void> Ext2FS::initialize_while_locked()
|
||||
|
||||
VERIFY((sizeof(ext2_super_block) % device_block_size()) == 0);
|
||||
auto super_block_buffer = UserOrKernelBuffer::for_kernel_buffer((u8*)&m_super_block);
|
||||
TRY(raw_read_blocks(1024 / device_block_size(), (sizeof(ext2_super_block) / device_block_size()), super_block_buffer));
|
||||
TRY(raw_read_blocks(super_block_offset_on_device / device_block_size(), (sizeof(ext2_super_block) / device_block_size()), super_block_buffer));
|
||||
|
||||
auto const& super_block = this->super_block();
|
||||
if constexpr (EXT2_DEBUG) {
|
||||
|
||||
Reference in New Issue
Block a user