Whamcloud - gitweb
Merge branch 'maint' into next
[tools/e2fsprogs.git] / misc / dumpe2fs.c
1 /*
2  * dumpe2fs.c           - List the control structures of a second
3  *                        extended filesystem
4  *
5  * Copyright (C) 1992, 1993, 1994  Remy Card <card@masi.ibp.fr>
6  *                                 Laboratoire MASI, Institut Blaise Pascal
7  *                                 Universite Pierre et Marie Curie (Paris VI)
8  *
9  * Copyright 1995, 1996, 1997 by Theodore Ts'o.
10  *
11  * %Begin-Header%
12  * This file may be redistributed under the terms of the GNU Public
13  * License.
14  * %End-Header%
15  */
16
17 /*
18  * History:
19  * 94/01/09     - Creation
20  * 94/02/27     - Ported to use the ext2fs library
21  */
22
23 #include "config.h"
24 #ifdef HAVE_GETOPT_H
25 #include <getopt.h>
26 #else
27 extern char *optarg;
28 extern int optind;
29 #endif
30 #include <fcntl.h>
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <string.h>
34 #include <unistd.h>
35
36 #include "ext2fs/ext2_fs.h"
37
38 #include "ext2fs/ext2fs.h"
39 #include "e2p/e2p.h"
40 #include "jfs_user.h"
41 #include <uuid/uuid.h>
42
43 #include "../version.h"
44 #include "nls-enable.h"
45
46 #define in_use(m, x)    (ext2fs_test_bit ((x), (m)))
47
48 const char * program_name = "dumpe2fs";
49 char * device_name = NULL;
50 int hex_format = 0;
51 int blocks64 = 0;
52
53 static void usage(void)
54 {
55         fprintf (stderr, _("Usage: %s [-bfhixV] [-o superblock=<num>] "
56                  "[-o blocksize=<num>] device\n"), program_name);
57         exit (1);
58 }
59
60 static void print_number(unsigned long long num)
61 {
62         if (hex_format) {
63                 if (blocks64)
64                         printf("0x%08llx", num);
65                 else
66                         printf("0x%04llx", num);
67         } else
68                 printf("%llu", num);
69 }
70
71 static void print_range(unsigned long long a, unsigned long long b)
72 {
73         if (hex_format) {
74                 if (blocks64)
75                         printf("0x%08llx-0x%08llx", a, b);
76                 else
77                         printf("0x%04llx-0x%04llx", a, b);
78         } else
79                 printf("%llu-%llu", a, b);
80 }
81
82 static void print_free(unsigned long group, char * bitmap,
83                        unsigned long num, unsigned long offset, int ratio)
84 {
85         int p = 0;
86         unsigned long i;
87         unsigned long j;
88
89         offset /= ratio;
90         offset += group * num;
91         for (i = 0; i < num; i++)
92                 if (!in_use (bitmap, i))
93                 {
94                         if (p)
95                                 printf (", ");
96                         print_number((i + offset) * ratio);
97                         for (j = i; j < num && !in_use (bitmap, j); j++)
98                                 ;
99                         if (--j != i) {
100                                 fputc('-', stdout);
101                                 print_number((j + offset) * ratio);
102                                 i = j;
103                         }
104                         p = 1;
105                 }
106 }
107
108 static void print_bg_opt(int bg_flags, int mask,
109                           const char *str, int *first)
110 {
111         if (bg_flags & mask) {
112                 if (*first) {
113                         fputs(" [", stdout);
114                         *first = 0;
115                 } else
116                         fputs(", ", stdout);
117                 fputs(str, stdout);
118         }
119 }
120 static void print_bg_opts(ext2_filsys fs, dgrp_t i)
121 {
122         int first = 1, bg_flags = 0;
123
124         if (ext2fs_has_group_desc_csum(fs))
125                 bg_flags = ext2fs_bg_flags(fs, i);
126
127         print_bg_opt(bg_flags, EXT2_BG_INODE_UNINIT, "INODE_UNINIT",
128                      &first);
129         print_bg_opt(bg_flags, EXT2_BG_BLOCK_UNINIT, "BLOCK_UNINIT",
130                      &first);
131         print_bg_opt(bg_flags, EXT2_BG_INODE_ZEROED, "ITABLE_ZEROED",
132                      &first);
133         if (!first)
134                 fputc(']', stdout);
135         fputc('\n', stdout);
136 }
137
138 static void print_bg_rel_offset(ext2_filsys fs, blk64_t block, int itable,
139                                 blk64_t first_block, blk64_t last_block)
140 {
141         if ((block >= first_block) && (block <= last_block)) {
142                 if (itable && block == first_block)
143                         return;
144                 printf(" (+%u)", (unsigned)(block - first_block));
145         } else if (fs->super->s_feature_incompat &
146                    EXT4_FEATURE_INCOMPAT_FLEX_BG) {
147                 dgrp_t flex_grp = ext2fs_group_of_blk2(fs, block);
148                 printf(" (bg #%u + %u)", flex_grp,
149                        (unsigned)(block-ext2fs_group_first_block2(fs,flex_grp)));
150         }
151 }
152
153 static void list_desc (ext2_filsys fs)
154 {
155         unsigned long i;
156         blk64_t first_block, last_block;
157         blk64_t super_blk, old_desc_blk, new_desc_blk;
158         char *block_bitmap=NULL, *inode_bitmap=NULL;
159         const char *units = _("blocks");
160         int inode_blocks_per_group, old_desc_blocks, reserved_gdt;
161         int             block_nbytes, inode_nbytes;
162         int has_super;
163         blk64_t         blk_itr = EXT2FS_B2C(fs, fs->super->s_first_data_block);
164         ext2_ino_t      ino_itr = 1;
165         errcode_t       retval;
166
167         if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
168                                        EXT4_FEATURE_RO_COMPAT_BIGALLOC))
169                 units = _("clusters");
170
171         block_nbytes = EXT2_CLUSTERS_PER_GROUP(fs->super) / 8;
172         inode_nbytes = EXT2_INODES_PER_GROUP(fs->super) / 8;
173
174         if (fs->block_map)
175                 block_bitmap = malloc(block_nbytes);
176         if (fs->inode_map)
177                 inode_bitmap = malloc(inode_nbytes);
178
179         inode_blocks_per_group = ((fs->super->s_inodes_per_group *
180                                    EXT2_INODE_SIZE(fs->super)) +
181                                   EXT2_BLOCK_SIZE(fs->super) - 1) /
182                                  EXT2_BLOCK_SIZE(fs->super);
183         reserved_gdt = fs->super->s_reserved_gdt_blocks;
184         fputc('\n', stdout);
185         first_block = fs->super->s_first_data_block;
186         if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG)
187                 old_desc_blocks = fs->super->s_first_meta_bg;
188         else
189                 old_desc_blocks = fs->desc_blocks;
190         for (i = 0; i < fs->group_desc_count; i++) {
191                 first_block = ext2fs_group_first_block2(fs, i);
192                 last_block = ext2fs_group_last_block2(fs, i);
193
194                 ext2fs_super_and_bgd_loc2(fs, i, &super_blk,
195                                           &old_desc_blk, &new_desc_blk, 0);
196
197                 printf (_("Group %lu: (Blocks "), i);
198                 print_range(first_block, last_block);
199                 fputs(")", stdout);
200                 print_bg_opts(fs, i);
201                 if (ext2fs_has_group_desc_csum(fs)) {
202                         unsigned csum = ext2fs_bg_checksum(fs, i);
203                         unsigned exp_csum = ext2fs_group_desc_csum(fs, i);
204
205                         printf(_("  Checksum 0x%04x"), csum);
206                         if (csum != exp_csum)
207                                 printf(_(" (EXPECTED 0x%04x)"), exp_csum);
208                         printf(_(", unused inodes %u\n"),
209                                ext2fs_bg_itable_unused(fs, i));
210                 }
211                 has_super = ((i==0) || super_blk);
212                 if (has_super) {
213                         printf (_("  %s superblock at "),
214                                 i == 0 ? _("Primary") : _("Backup"));
215                         print_number(super_blk);
216                 }
217                 if (old_desc_blk) {
218                         printf("%s", _(", Group descriptors at "));
219                         print_range(old_desc_blk,
220                                     old_desc_blk + old_desc_blocks - 1);
221                         if (reserved_gdt) {
222                                 printf("%s", _("\n  Reserved GDT blocks at "));
223                                 print_range(old_desc_blk + old_desc_blocks,
224                                             old_desc_blk + old_desc_blocks +
225                                             reserved_gdt - 1);
226                         }
227                 } else if (new_desc_blk) {
228                         fputc(has_super ? ',' : ' ', stdout);
229                         printf("%s", _(" Group descriptor at "));
230                         print_number(new_desc_blk);
231                         has_super++;
232                 }
233                 if (has_super)
234                         fputc('\n', stdout);
235                 fputs(_("  Block bitmap at "), stdout);
236                 print_number(ext2fs_block_bitmap_loc(fs, i));
237                 print_bg_rel_offset(fs, ext2fs_block_bitmap_loc(fs, i), 0,
238                                     first_block, last_block);
239                 if (fs->super->s_feature_ro_compat &
240                     EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)
241                         printf(_(", csum 0x%08x"),
242                                ext2fs_block_bitmap_checksum(fs, i));
243                 fputs(_(", Inode bitmap at "), stdout);
244                 print_number(ext2fs_inode_bitmap_loc(fs, i));
245                 print_bg_rel_offset(fs, ext2fs_inode_bitmap_loc(fs, i), 0,
246                                     first_block, last_block);
247                 if (fs->super->s_feature_ro_compat &
248                     EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)
249                         printf(_(", csum 0x%08x"),
250                                ext2fs_inode_bitmap_checksum(fs, i));
251                 fputs(_("\n  Inode table at "), stdout);
252                 print_range(ext2fs_inode_table_loc(fs, i),
253                             ext2fs_inode_table_loc(fs, i) +
254                             inode_blocks_per_group - 1);
255                 print_bg_rel_offset(fs, ext2fs_inode_table_loc(fs, i), 1,
256                                     first_block, last_block);
257                 printf (_("\n  %u free %s, %u free inodes, "
258                           "%u directories%s"),
259                         ext2fs_bg_free_blocks_count(fs, i), units,
260                         ext2fs_bg_free_inodes_count(fs, i),
261                         ext2fs_bg_used_dirs_count(fs, i),
262                         ext2fs_bg_itable_unused(fs, i) ? "" : "\n");
263                 if (ext2fs_bg_itable_unused(fs, i))
264                         printf (_(", %u unused inodes\n"),
265                                 ext2fs_bg_itable_unused(fs, i));
266                 if (block_bitmap) {
267                         fputs(_("  Free blocks: "), stdout);
268                         retval = ext2fs_get_block_bitmap_range2(fs->block_map,
269                                  blk_itr, block_nbytes << 3, block_bitmap);
270                         if (retval)
271                                 com_err("list_desc", retval,
272                                         "while reading block bitmap");
273                         else
274                                 print_free(i, block_bitmap,
275                                            fs->super->s_clusters_per_group,
276                                            fs->super->s_first_data_block,
277                                            EXT2FS_CLUSTER_RATIO(fs));
278                         fputc('\n', stdout);
279                         blk_itr += fs->super->s_clusters_per_group;
280                 }
281                 if (inode_bitmap) {
282                         fputs(_("  Free inodes: "), stdout);
283                         retval = ext2fs_get_inode_bitmap_range2(fs->inode_map,
284                                  ino_itr, inode_nbytes << 3, inode_bitmap);
285                         if (retval)
286                                 com_err("list_desc", retval,
287                                         "while reading inode bitmap");
288                         else
289                                 print_free(i, inode_bitmap,
290                                            fs->super->s_inodes_per_group,
291                                            1, 1);
292                         fputc('\n', stdout);
293                         ino_itr += fs->super->s_inodes_per_group;
294                 }
295         }
296         if (block_bitmap)
297                 free(block_bitmap);
298         if (inode_bitmap)
299                 free(inode_bitmap);
300 }
301
302 static void list_bad_blocks(ext2_filsys fs, int dump)
303 {
304         badblocks_list          bb_list = 0;
305         badblocks_iterate       bb_iter;
306         blk_t                   blk;
307         errcode_t               retval;
308         const char              *header, *fmt;
309
310         retval = ext2fs_read_bb_inode(fs, &bb_list);
311         if (retval) {
312                 com_err("ext2fs_read_bb_inode", retval, 0);
313                 return;
314         }
315         retval = ext2fs_badblocks_list_iterate_begin(bb_list, &bb_iter);
316         if (retval) {
317                 com_err("ext2fs_badblocks_list_iterate_begin", retval,
318                         "%s", _("while printing bad block list"));
319                 return;
320         }
321         if (dump) {
322                 header = fmt = "%u\n";
323         } else {
324                 header =  _("Bad blocks: %u");
325                 fmt = ", %u";
326         }
327         while (ext2fs_badblocks_list_iterate(bb_iter, &blk)) {
328                 printf(header ? header : fmt, blk);
329                 header = 0;
330         }
331         ext2fs_badblocks_list_iterate_end(bb_iter);
332         if (!dump)
333                 fputc('\n', stdout);
334         ext2fs_badblocks_list_free(bb_list);
335 }
336
337 static const char *journal_checksum_type_str(__u8 type)
338 {
339         switch (type) {
340         case JBD2_CRC32C_CHKSUM:
341                 return "crc32c";
342         default:
343                 return "unknown";
344         }
345 }
346
347 static void print_inline_journal_information(ext2_filsys fs)
348 {
349         journal_superblock_t    *jsb;
350         struct ext2_inode       inode;
351         ext2_file_t             journal_file;
352         errcode_t               retval;
353         ino_t                   ino = fs->super->s_journal_inum;
354         char                    buf[1024];
355         __u32                   *mask_ptr, mask, m;
356         int                     i, j, size, printed = 0;
357
358         retval = ext2fs_read_inode(fs, ino,  &inode);
359         if (retval) {
360                 com_err(program_name, retval, "%s",
361                         _("while reading journal inode"));
362                 exit(1);
363         }
364         retval = ext2fs_file_open2(fs, ino, &inode, 0, &journal_file);
365         if (retval) {
366                 com_err(program_name, retval, "%s",
367                         _("while opening journal inode"));
368                 exit(1);
369         }
370         retval = ext2fs_file_read(journal_file, buf, sizeof(buf), 0);
371         if (retval) {
372                 com_err(program_name, retval, "%s",
373                         _("while reading journal super block"));
374                 exit(1);
375         }
376         ext2fs_file_close(journal_file);
377         jsb = (journal_superblock_t *) buf;
378         if (be32_to_cpu(jsb->s_header.h_magic) != JFS_MAGIC_NUMBER) {
379                 fprintf(stderr, "%s",
380                         _("Journal superblock magic number invalid!\n"));
381                 exit(1);
382         }
383         printf("%s", _("Journal features:        "));
384         for (i=0, mask_ptr=&jsb->s_feature_compat; i <3; i++,mask_ptr++) {
385                 mask = be32_to_cpu(*mask_ptr);
386                 for (j=0,m=1; j < 32; j++, m<<=1) {
387                         if (mask & m) {
388                                 printf(" %s", e2p_jrnl_feature2string(i, m));
389                                 printed++;
390                         }
391                 }
392         }
393         if (printed == 0)
394                 printf(" (none)");
395         printf("\n");
396         fputs(_("Journal size:             "), stdout);
397         if ((fs->super->s_feature_ro_compat &
398              EXT4_FEATURE_RO_COMPAT_HUGE_FILE) &&
399             (inode.i_flags & EXT4_HUGE_FILE_FL))
400                 size = inode.i_blocks / (fs->blocksize / 1024);
401         else
402                 size = inode.i_blocks >> 1;
403         if (size < 8192)
404                 printf("%uk\n", size);
405         else
406                 printf("%uM\n", size >> 10);
407         printf(_("Journal length:           %u\n"
408                  "Journal sequence:         0x%08x\n"
409                  "Journal start:            %u\n"),
410                (unsigned int)ntohl(jsb->s_maxlen),
411                (unsigned int)ntohl(jsb->s_sequence),
412                (unsigned int)ntohl(jsb->s_start));
413         if (jsb->s_feature_compat &
414             ext2fs_cpu_to_be32(JFS_FEATURE_COMPAT_CHECKSUM))
415                 printf(_("Journal checksum type:    crc32\n"));
416         if (jsb->s_feature_incompat &
417             ext2fs_cpu_to_be32(JFS_FEATURE_INCOMPAT_CSUM_V2))
418                 printf(_("Journal checksum type:    %s\n"
419                          "Journal checksum:         0x%08x\n"),
420                        journal_checksum_type_str(jsb->s_checksum_type),
421                        ext2fs_be32_to_cpu(jsb->s_checksum));
422         if (jsb->s_errno != 0)
423                 printf(_("Journal errno:            %d\n"),
424                        (int) ntohl(jsb->s_errno));
425 }
426
427 static void print_journal_information(ext2_filsys fs)
428 {
429         errcode_t       retval;
430         char            buf[1024];
431         char            str[80];
432         unsigned int    i;
433         journal_superblock_t    *jsb;
434
435         /* Get the journal superblock */
436         if ((retval = io_channel_read_blk64(fs->io,
437                                             fs->super->s_first_data_block + 1,
438                                             -1024, buf))) {
439                 com_err(program_name, retval, "%s",
440                         _("while reading journal superblock"));
441                 exit(1);
442         }
443         jsb = (journal_superblock_t *) buf;
444         if ((jsb->s_header.h_magic != (unsigned) ntohl(JFS_MAGIC_NUMBER)) ||
445             (jsb->s_header.h_blocktype !=
446              (unsigned) ntohl(JFS_SUPERBLOCK_V2))) {
447                 com_err(program_name, 0, "%s",
448                         _("Couldn't find journal superblock magic numbers"));
449                 exit(1);
450         }
451
452         if (jsb->s_feature_compat &
453             ext2fs_cpu_to_be32(JFS_FEATURE_COMPAT_CHECKSUM))
454                 printf(_("Journal checksum type:    crc32\n"));
455         if (jsb->s_feature_incompat &
456             ext2fs_cpu_to_be32(JFS_FEATURE_INCOMPAT_CSUM_V2))
457                 printf(_("Journal checksum type:    %s\n"
458                          "Journal checksum:         0x%08x\n"),
459                        journal_checksum_type_str(jsb->s_checksum_type),
460                        ext2fs_be32_to_cpu(jsb->s_checksum));
461
462         printf(_("\nJournal block size:       %u\n"
463                  "Journal length:           %u\n"
464                  "Journal first block:      %u\n"
465                  "Journal sequence:         0x%08x\n"
466                  "Journal start:            %u\n"
467                  "Journal number of users:  %u\n"),
468                (unsigned int)ntohl(jsb->s_blocksize),  (unsigned int)ntohl(jsb->s_maxlen),
469                (unsigned int)ntohl(jsb->s_first), (unsigned int)ntohl(jsb->s_sequence),
470                (unsigned int)ntohl(jsb->s_start), (unsigned int)ntohl(jsb->s_nr_users));
471
472         for (i=0; i < ntohl(jsb->s_nr_users); i++) {
473                 uuid_unparse(&jsb->s_users[i*16], str);
474                 printf(i ? "                          %s\n"
475                        : _("Journal users:            %s\n"),
476                        str);
477         }
478 }
479
480 static void parse_extended_opts(const char *opts, blk64_t *superblock,
481                                 int *blocksize)
482 {
483         char    *buf, *token, *next, *p, *arg, *badopt = 0;
484         int     len;
485         int     do_usage = 0;
486
487         len = strlen(opts);
488         buf = malloc(len+1);
489         if (!buf) {
490                 fprintf(stderr, "%s",
491                         _("Couldn't allocate memory to parse options!\n"));
492                 exit(1);
493         }
494         strcpy(buf, opts);
495         for (token = buf; token && *token; token = next) {
496                 p = strchr(token, ',');
497                 next = 0;
498                 if (p) {
499                         *p = 0;
500                         next = p+1;
501                 }
502                 arg = strchr(token, '=');
503                 if (arg) {
504                         *arg = 0;
505                         arg++;
506                 }
507                 if (strcmp(token, "superblock") == 0 ||
508                     strcmp(token, "sb") == 0) {
509                         if (!arg) {
510                                 do_usage++;
511                                 badopt = token;
512                                 continue;
513                         }
514                         *superblock = strtoul(arg, &p, 0);
515                         if (*p) {
516                                 fprintf(stderr,
517                                         _("Invalid superblock parameter: %s\n"),
518                                         arg);
519                                 do_usage++;
520                                 continue;
521                         }
522                 } else if (strcmp(token, "blocksize") == 0 ||
523                            strcmp(token, "bs") == 0) {
524                         if (!arg) {
525                                 do_usage++;
526                                 badopt = token;
527                                 continue;
528                         }
529                         *blocksize = strtoul(arg, &p, 0);
530                         if (*p) {
531                                 fprintf(stderr,
532                                         _("Invalid blocksize parameter: %s\n"),
533                                         arg);
534                                 do_usage++;
535                                 continue;
536                         }
537                 } else {
538                         do_usage++;
539                         badopt = token;
540                 }
541         }
542         if (do_usage) {
543                 fprintf(stderr, _("\nBad extended option(s) specified: %s\n\n"
544                         "Extended options are separated by commas, "
545                         "and may take an argument which\n"
546                         "\tis set off by an equals ('=') sign.\n\n"
547                         "Valid extended options are:\n"
548                         "\tsuperblock=<superblock number>\n"
549                         "\tblocksize=<blocksize>\n"),
550                         badopt ? badopt : "");
551                 free(buf);
552                 exit(1);
553         }
554         free(buf);
555 }
556
557 int main (int argc, char ** argv)
558 {
559         errcode_t       retval;
560         ext2_filsys     fs;
561         int             print_badblocks = 0;
562         blk64_t         use_superblock = 0;
563         int             use_blocksize = 0;
564         int             image_dump = 0;
565         int             force = 0;
566         int             flags;
567         int             header_only = 0;
568         int             c;
569
570 #ifdef ENABLE_NLS
571         setlocale(LC_MESSAGES, "");
572         setlocale(LC_CTYPE, "");
573         bindtextdomain(NLS_CAT_NAME, LOCALEDIR);
574         textdomain(NLS_CAT_NAME);
575         set_com_err_gettext(gettext);
576 #endif
577         add_error_table(&et_ext2_error_table);
578         fprintf (stderr, "dumpe2fs %s (%s)\n", E2FSPROGS_VERSION,
579                  E2FSPROGS_DATE);
580         if (argc && *argv)
581                 program_name = *argv;
582
583         while ((c = getopt (argc, argv, "bfhixVo:")) != EOF) {
584                 switch (c) {
585                 case 'b':
586                         print_badblocks++;
587                         break;
588                 case 'f':
589                         force++;
590                         break;
591                 case 'h':
592                         header_only++;
593                         break;
594                 case 'i':
595                         image_dump++;
596                         break;
597                 case 'o':
598                         parse_extended_opts(optarg, &use_superblock,
599                                             &use_blocksize);
600                         break;
601                 case 'V':
602                         /* Print version number and exit */
603                         fprintf(stderr, _("\tUsing %s\n"),
604                                 error_message(EXT2_ET_BASE));
605                         exit(0);
606                 case 'x':
607                         hex_format++;
608                         break;
609                 default:
610                         usage();
611                 }
612         }
613         if (optind > argc - 1)
614                 usage();
615         device_name = argv[optind++];
616         flags = EXT2_FLAG_JOURNAL_DEV_OK | EXT2_FLAG_SOFTSUPP_FEATURES | EXT2_FLAG_64BITS;
617         if (force)
618                 flags |= EXT2_FLAG_FORCE;
619         if (image_dump)
620                 flags |= EXT2_FLAG_IMAGE_FILE;
621
622         if (use_superblock && !use_blocksize) {
623                 for (use_blocksize = EXT2_MIN_BLOCK_SIZE;
624                      use_blocksize <= EXT2_MAX_BLOCK_SIZE;
625                      use_blocksize *= 2) {
626                         retval = ext2fs_open (device_name, flags,
627                                               use_superblock,
628                                               use_blocksize, unix_io_manager,
629                                               &fs);
630                         if (!retval)
631                                 break;
632                 }
633         } else
634                 retval = ext2fs_open (device_name, flags, use_superblock,
635                                       use_blocksize, unix_io_manager, &fs);
636         if (retval) {
637                 com_err (program_name, retval, _("while trying to open %s"),
638                          device_name);
639                 printf("%s", _("Couldn't find valid filesystem superblock.\n"));
640                 exit (1);
641         }
642         fs->default_bitmap_type = EXT2FS_BMAP64_RBTREE;
643         if (fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT)
644                 blocks64 = 1;
645         if (print_badblocks) {
646                 list_bad_blocks(fs, 1);
647         } else {
648                 list_super (fs->super);
649                 if (fs->super->s_feature_incompat &
650                       EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) {
651                         print_journal_information(fs);
652                         ext2fs_close(fs);
653                         exit(0);
654                 }
655                 if ((fs->super->s_feature_compat &
656                      EXT3_FEATURE_COMPAT_HAS_JOURNAL) &&
657                     (fs->super->s_journal_inum != 0))
658                         print_inline_journal_information(fs);
659                 list_bad_blocks(fs, 0);
660                 if (header_only) {
661                         ext2fs_close (fs);
662                         exit (0);
663                 }
664                 retval = ext2fs_read_bitmaps (fs);
665                 list_desc (fs);
666                 if (retval) {
667                         printf(_("\n%s: %s: error reading bitmaps: %s\n"),
668                                program_name, device_name,
669                                error_message(retval));
670                 }
671         }
672         ext2fs_close (fs);
673         remove_error_table(&et_ext2_error_table);
674         exit (0);
675 }