summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-06-09 14:58:32 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-06-09 14:59:46 +0200
commit51d70996ba40eaae35f2b40e03f3e52f39242c80 (patch)
tree271fe5ae90b5f5bc5cf54f6895c057a95707d42b /Kernel/FileSystem
parent7562c0b7bf0343d14e3da37b5d5e6e2d59c565af (diff)
downloadserenity-51d70996ba40eaae35f2b40e03f3e52f39242c80.zip
Ext2FS: The block numbers returned by allocate_blocks() should be 1-based.
e2fsck complained about two inodes sharing the same block, and this was why.
Diffstat (limited to 'Kernel/FileSystem')
-rw-r--r--Kernel/FileSystem/Ext2FileSystem.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp
index fe2a1d726e..0f85b40892 100644
--- a/Kernel/FileSystem/Ext2FileSystem.cpp
+++ b/Kernel/FileSystem/Ext2FileSystem.cpp
@@ -881,7 +881,7 @@ Vector<Ext2FS::BlockIndex> Ext2FS::allocate_blocks(GroupIndex group_index, int c
auto bitmap_block = read_block(bgd.bg_block_bitmap);
int blocks_in_group = min(blocks_per_group(), super_block().s_blocks_count);
auto block_bitmap = Bitmap::wrap(bitmap_block.pointer(), blocks_in_group);
- BlockIndex first_block_in_group = (group_index - 1) * blocks_per_group();
+ BlockIndex first_block_in_group = (group_index - 1) * blocks_per_group() + 1;
for (int i = 0; i < block_bitmap.size(); ++i) {
if (!block_bitmap.get(i)) {
blocks.append(first_block_in_group + i);
@@ -1041,7 +1041,7 @@ bool Ext2FS::set_block_allocation_state(BlockIndex block_index, bool new_state)
#endif
unsigned group_index = group_index_from_block_index(block_index);
auto& bgd = group_descriptor(group_index);
- BlockIndex index_in_group = block_index - ((group_index - 1) * blocks_per_group());
+ BlockIndex index_in_group = (block_index - 1) - ((group_index - 1) * blocks_per_group());
unsigned bit_index = index_in_group % blocks_per_group();
#ifdef EXT2_DEBUG
dbgprintf(" index_in_group: %u\n", index_in_group);