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:
brody-qq
2024-07-18 16:08:21 +01:00
committed by Nico Weber
parent 416875f952
commit f3f681ae45
2 changed files with 3 additions and 3 deletions

View File

@@ -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) {