From 04bb2e97c651ce4b3eef97ced31fae16b30e53bc Mon Sep 17 00:00:00 2001 From: pjht Date: Fri, 27 Sep 2024 13:36:02 -0500 Subject: [PATCH] Fix doubly and triply indirect blocks --- src/ext2/structs.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ext2/structs.rs b/src/ext2/structs.rs index ecdee80..8551049 100644 --- a/src/ext2/structs.rs +++ b/src/ext2/structs.rs @@ -194,7 +194,7 @@ impl Inode { Some(block) } } else if block < (12 + num_sing_indir + num_doub_indir) as u32 { - let base_block = 12 - num_sing_indir; + let base_block = 12 + num_sing_indir; let doub_indir_offset = (block as usize - base_block) / num_sing_indir; let sing_indir_offset = (block as usize - base_block) % num_sing_indir; let sing_indir_blocks = self @@ -210,7 +210,7 @@ impl Inode { Some(block) } } else if block < (12 + num_sing_indir + num_doub_indir + num_trip_indir) as u32 { - let base_block = 12 - num_sing_indir; + let base_block = 12 + num_sing_indir + num_doub_indir; let trip_indir_offset = (block as usize - base_block) / num_doub_indir; let doub_indir_offset = ((block as usize - base_block) % num_doub_indir) / num_sing_indir;