diff options
author | Theodore Ts'o <tytso@mit.edu> | 2012-05-14 01:59:32 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2012-05-14 01:59:32 -0400 |
commit | ce10c313e618826544779ec26432a6ffb0cbb684 (patch) | |
tree | e7696fa676e2557c537e536d4aff37117370d11a | |
parent | 183c73b02615acc33fc22e89b8cc7fdc5f22ee0e (diff) | |
download | e2fsprogs-ce10c313e618826544779ec26432a6ffb0cbb684.tar.gz |
dumpe2fs: fix 64-bit block numbers on 32-bit systems
Fix bug which caused 64-bit block numbers to be incorrectly printed on
systems with 32-bit longs.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
-rw-r--r-- | misc/dumpe2fs.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/misc/dumpe2fs.c b/misc/dumpe2fs.c index b91c3831..8f4f2e4e 100644 --- a/misc/dumpe2fs.c +++ b/misc/dumpe2fs.c @@ -48,6 +48,7 @@ extern int optind; const char * program_name = "dumpe2fs"; char * device_name = NULL; int hex_format = 0; +int blocks64 = 0; static void usage(void) { @@ -56,19 +57,25 @@ static void usage(void) exit (1); } -static void print_number(unsigned long num) +static void print_number(unsigned long long num) { - if (hex_format) - printf("0x%04lx", num); - else - printf("%lu", num); + if (hex_format) { + if (blocks64) + printf("0x%08llx", num); + else + printf("0x%04llx", num); + } else + printf("%llu", num); } static void print_range(unsigned long long a, unsigned long long b) { - if (hex_format) - printf("0x%llx-0x%llx", a, b); - else + if (hex_format) { + if (blocks64) + printf("0x%08llx-0x%08llx", a, b); + else + printf("0x%04llx-0x%04llx", a, b); + } else printf("%llu-%llu", a, b); } @@ -581,6 +588,8 @@ int main (int argc, char ** argv) exit (1); } fs->default_bitmap_type = EXT2FS_BMAP64_RBTREE; + if (fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT) + blocks64 = 1; if (print_badblocks) { list_bad_blocks(fs, 1); } else { |