debugfs: fix debugfs dump for a hashed directory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



debugfs produce wrong output for a htree command in some cases.
sync a htree structures with in kernel implementation.

---
 debugfs/htree.c      |  6 +++---
 lib/ext2fs/ext2_fs.h | 14 ++++++++++++++
 lib/ext2fs/ext2fs.h  |  2 +-
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/debugfs/htree.c b/debugfs/htree.c
index 24f8250..d47793a 100644
--- a/debugfs/htree.c
+++ b/debugfs/htree.c
@@ -185,7 +185,7 @@ static void htree_dump_int_block(ext2_filsys fs, ext2_ino_t ino,
 	}
 
 	htree_dump_int_node(fs, ino, inode, rootnode,
-			    (struct ext2_dx_entry *) (buf+8),
+			    ((struct ext2_dx_node *)buf)->entries,
 			    cbuf, level);
 errout:
 	free(cbuf);
@@ -244,7 +244,7 @@ void do_htree_dump(int argc, char *argv[])
 		goto errout;
 	}
 
-	rootnode = (struct ext2_dx_root_info *) (buf + 24);
+	rootnode = get_ext2_dx_root_info(current_fs, buf);
 
 	fprintf(pager, "Root node dump:\n");
 	fprintf(pager, "\t Reserved zero: %u\n", rootnode->reserved_zero);
@@ -253,7 +253,7 @@ void do_htree_dump(int argc, char *argv[])
 	fprintf(pager, "\t Indirect levels: %d\n", rootnode->indirect_levels);
 	fprintf(pager, "\t Flags: %d\n", rootnode->unused_flags);
 
-	ent = (struct ext2_dx_entry *) (buf + 24 + rootnode->info_length);
+	ent = (struct ext2_dx_entry *) ((char *)rootnode + rootnode->info_length);
 
 	htree_dump_int_node(current_fs, ino, &inode, rootnode, ent,
 			    buf + current_fs->blocksize,
diff --git a/lib/ext2fs/ext2_fs.h b/lib/ext2fs/ext2_fs.h
index 8965f4c..d1397db 100644
--- a/lib/ext2fs/ext2_fs.h
+++ b/lib/ext2fs/ext2_fs.h
@@ -235,6 +235,20 @@ struct ext2_dx_countlimit {
 	__u16 count;
 };
 
+struct fake_dirent
+{
+	__u32 inode;
+	__u16 rec_len;
+	__u8 name_len;
+	__u8 file_type;
+};
+
+struct ext2_dx_node
+{
+	struct fake_dirent fake;
+	struct ext2_dx_entry	entries[0];
+};
+
 
 /*
  * Macro-instructions used to manage group descriptors

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux