From: Theodore Ts'o Date: Fri, 19 Jul 2002 02:19:51 +0000 (-0400) Subject: htree.c (htree_dump_int_node): Add byte swapping code sot that X-Git-Tag: E2FSPROGS-1.28-WIP-0817~31 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=621732c956f8ff049d032354fc8d6eab9abab1f4;p=thirdparty%2Fe2fsprogs.git htree.c (htree_dump_int_node): Add byte swapping code sot that the htree dump function works on a big-endian machine. --- diff --git a/debugfs/ChangeLog b/debugfs/ChangeLog index aacb43da6..7ddbd21ae 100644 --- a/debugfs/ChangeLog +++ b/debugfs/ChangeLog @@ -1,3 +1,8 @@ +2002-07-18 Theodore Ts'o + + * htree.c (htree_dump_int_node): Add byte swapping code sot that + the htree dump function works on a big-endian machine. + 2002-07-15 Theodore Ts'o * debugfs.c (do_show_super_stats): Calculate and print the number diff --git a/debugfs/htree.c b/debugfs/htree.c index 0da7c55d3..e58384990 100644 --- a/debugfs/htree.c +++ b/debugfs/htree.c @@ -102,29 +102,36 @@ static void htree_dump_int_node(ext2_filsys fs, ext2_ino_t ino, struct ext2_dx_entry *ent, char *buf, int level) { - struct ext2_dx_countlimit *limit; - int i; + struct ext2_dx_countlimit limit; + struct ext2_dx_entry e; + int i; + - limit = (struct ext2_dx_countlimit *) ent; + limit = *((struct ext2_dx_countlimit *) ent); + limit.count = ext2fs_le16_to_cpu(limit.count); + limit.limit = ext2fs_le16_to_cpu(limit.limit); - fprintf(pager, "Number of entries (count): %d\n", limit->count); - fprintf(pager, "Number of entries (limit): %d\n", limit->limit); + fprintf(pager, "Number of entries (count): %d\n", limit.count); + fprintf(pager, "Number of entries (limit): %d\n", limit.limit); - for (i=0; i < limit->count; i++) + for (i=0; i < limit.count; i++) fprintf(pager, "Entry #%d: Hash 0x%08x, block %d\n", i, - i ? ent[i].hash : 0, ent[i].block); + i ? ext2fs_le32_to_cpu(ent[i].hash) : 0, + ext2fs_le32_to_cpu(ent[i].block)); fprintf(pager, "\n"); - for (i=0; i < limit->count; i++) { + for (i=0; i < limit.count; i++) { + e.hash = ext2fs_le32_to_cpu(ent[i].hash); + e.block = ext2fs_le32_to_cpu(ent[i].block); fprintf(pager, "Entry #%d: Hash 0x%08x, block %d\n", i, - i ? ent[i].hash : 0, ent[i].block); + i ? e.hash : 0, e.block); if (level) htree_dump_int_block(fs, ino, inode, root, - ent[i].block, buf, level-1); + e.block, buf, level-1); else htree_dump_leaf_node(fs, ino, inode, root, - ent[i].block, buf); + e.block, buf); } fprintf(pager, "---------------------\n");