blob: 0af1bad5742be240f49e8d100fe77bf5faccf5f9 [file] [log] [blame]
Theodore Ts'o3839e651997-04-26 13:21:57 +00001/*
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 *
Theodore Ts'o19c78dc1997-04-29 16:17:09 +00009 * 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%
Theodore Ts'o3839e651997-04-26 13:21:57 +000015 */
16
17/*
18 * History:
19 * 94/01/09 - Creation
20 * 94/02/27 - Ported to use the ext2fs library
21 */
22
Theodore Ts'oa418d3a1997-04-26 14:00:26 +000023#ifdef HAVE_GETOPT_H
Theodore Ts'o3839e651997-04-26 13:21:57 +000024#include <getopt.h>
Theodore Ts'o373b8332000-04-03 16:22:35 +000025#else
26extern char *optarg;
27extern int optind;
Theodore Ts'oa418d3a1997-04-26 14:00:26 +000028#endif
Theodore Ts'o3839e651997-04-26 13:21:57 +000029#include <fcntl.h>
30#include <stdio.h>
31#include <stdlib.h>
32#include <string.h>
33#include <unistd.h>
34
Theodore Ts'o54c637d2001-05-14 11:45:38 +000035#include "ext2fs/ext2_fs.h"
Theodore Ts'o3839e651997-04-26 13:21:57 +000036
37#include "ext2fs/ext2fs.h"
38#include "e2p/e2p.h"
Theodore Ts'o16ed5b32001-01-16 07:47:31 +000039#include "jfs_user.h"
Theodore Ts'o4ea7bd02001-12-16 23:23:37 -050040#include <uuid/uuid.h>
Theodore Ts'o3839e651997-04-26 13:21:57 +000041
42#include "../version.h"
Theodore Ts'od9c56d32000-02-08 00:47:55 +000043#include "nls-enable.h"
Theodore Ts'o3839e651997-04-26 13:21:57 +000044
Theodore Ts'o74becf31997-04-26 14:37:06 +000045#define in_use(m, x) (ext2fs_test_bit ((x), (m)))
Theodore Ts'o3839e651997-04-26 13:21:57 +000046
47const char * program_name = "dumpe2fs";
48char * device_name = NULL;
Theodore Ts'o9b9a7802005-12-10 21:50:30 -050049int hex_format = 0;
Theodore Ts'o3839e651997-04-26 13:21:57 +000050
Theodore Ts'o818180c1998-06-27 05:11:14 +000051static void usage(void)
Theodore Ts'o3839e651997-04-26 13:21:57 +000052{
Theodore Ts'o348e43d2001-05-03 14:43:43 +000053 fprintf (stderr, _("Usage: %s [-bfhixV] [-ob superblock] "
Theodore Ts'od9c56d32000-02-08 00:47:55 +000054 "[-oB blocksize] device\n"), program_name);
Theodore Ts'o3839e651997-04-26 13:21:57 +000055 exit (1);
56}
57
Theodore Ts'o9b9a7802005-12-10 21:50:30 -050058static void print_number(unsigned long num)
Theodore Ts'o54434922003-12-07 01:28:50 -050059{
Theodore Ts'o9b9a7802005-12-10 21:50:30 -050060 if (hex_format)
61 printf("0x%04lx", num);
62 else
63 printf("%lu", num);
64}
65
66static void print_range(unsigned long a, unsigned long b)
67{
68 if (hex_format)
69 printf("0x%04lx-0x%04lx", a, b);
70 else
71 printf("%lu-%lu", a, b);
Theodore Ts'o54434922003-12-07 01:28:50 -050072}
73
Theodore Ts'o3839e651997-04-26 13:21:57 +000074static void print_free (unsigned long group, char * bitmap,
75 unsigned long nbytes, unsigned long offset)
76{
77 int p = 0;
78 unsigned long i;
79 unsigned long j;
80
Theodore Ts'oa5f0bb92001-12-02 19:29:35 +010081 offset += group * nbytes;
Theodore Ts'o3839e651997-04-26 13:21:57 +000082 for (i = 0; i < nbytes; i++)
83 if (!in_use (bitmap, i))
84 {
85 if (p)
86 printf (", ");
Theodore Ts'o54434922003-12-07 01:28:50 -050087 print_number(i + offset);
Theodore Ts'oa5f0bb92001-12-02 19:29:35 +010088 for (j = i; j < nbytes && !in_use (bitmap, j); j++)
89 ;
90 if (--j != i) {
91 fputc('-', stdout);
Theodore Ts'o54434922003-12-07 01:28:50 -050092 print_number(j + offset);
Theodore Ts'oa5f0bb92001-12-02 19:29:35 +010093 i = j;
Theodore Ts'o3839e651997-04-26 13:21:57 +000094 }
95 p = 1;
96 }
97}
98
99static void list_desc (ext2_filsys fs)
100{
101 unsigned long i;
Theodore Ts'oa5f0bb92001-12-02 19:29:35 +0100102 long diff;
Theodore Ts'o521e3681997-04-29 17:48:10 +0000103 blk_t group_blk, next_blk;
Theodore Ts'oef344e12003-11-21 09:02:21 -0500104 blk_t super_blk, old_desc_blk, new_desc_blk;
Theodore Ts'od90a23e2002-10-25 17:07:11 -0400105 char *block_bitmap=NULL, *inode_bitmap=NULL;
Theodore Ts'o35238dd2004-12-23 13:54:28 -0500106 int inode_blocks_per_group, old_desc_blocks, reserved_gdt;
Theodore Ts'oef344e12003-11-21 09:02:21 -0500107 int has_super;
Theodore Ts'o80c22c92000-08-14 15:32:11 +0000108
Theodore Ts'od90a23e2002-10-25 17:07:11 -0400109 if (fs->block_map)
110 block_bitmap = fs->block_map->bitmap;
111 if (fs->inode_map)
112 inode_bitmap = fs->inode_map->bitmap;
113
Theodore Ts'o80c22c92000-08-14 15:32:11 +0000114 inode_blocks_per_group = ((fs->super->s_inodes_per_group *
115 EXT2_INODE_SIZE(fs->super)) +
116 EXT2_BLOCK_SIZE(fs->super) - 1) /
117 EXT2_BLOCK_SIZE(fs->super);
Theodore Ts'o35238dd2004-12-23 13:54:28 -0500118 reserved_gdt = fs->super->s_reserved_gdt_blocks;
Theodore Ts'oa5f0bb92001-12-02 19:29:35 +0100119 fputc('\n', stdout);
Theodore Ts'o521e3681997-04-29 17:48:10 +0000120 group_blk = fs->super->s_first_data_block;
Theodore Ts'o76dd5e52002-10-30 23:07:21 -0500121 if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG)
122 old_desc_blocks = fs->super->s_first_meta_bg;
123 else
124 old_desc_blocks = fs->desc_blocks;
Theodore Ts'o521e3681997-04-29 17:48:10 +0000125 for (i = 0; i < fs->group_desc_count; i++) {
Theodore Ts'oef344e12003-11-21 09:02:21 -0500126 ext2fs_super_and_bgd_loc(fs, i, &super_blk,
127 &old_desc_blk, &new_desc_blk, 0);
Theodore Ts'o521e3681997-04-29 17:48:10 +0000128 next_blk = group_blk + fs->super->s_blocks_per_group;
129 if (next_blk > fs->super->s_blocks_count)
130 next_blk = fs->super->s_blocks_count;
Theodore Ts'oa5f0bb92001-12-02 19:29:35 +0100131 printf (_("Group %lu: (Blocks "), i);
Theodore Ts'o9b9a7802005-12-10 21:50:30 -0500132 print_range(group_blk, next_blk - 1);
Theodore Ts'oa5f0bb92001-12-02 19:29:35 +0100133 fputs(")\n", stdout);
Theodore Ts'oef344e12003-11-21 09:02:21 -0500134 has_super = ((i==0) || super_blk);
Theodore Ts'oc046ac72002-10-20 00:38:57 -0400135 if (has_super) {
136 printf (_(" %s superblock at "),
Theodore Ts'oa5f0bb92001-12-02 19:29:35 +0100137 i == 0 ? _("Primary") : _("Backup"));
Theodore Ts'o54434922003-12-07 01:28:50 -0500138 print_number(super_blk);
Theodore Ts'oc046ac72002-10-20 00:38:57 -0400139 }
Theodore Ts'oef344e12003-11-21 09:02:21 -0500140 if (old_desc_blk) {
141 printf(_(", Group descriptors at "));
Theodore Ts'o9b9a7802005-12-10 21:50:30 -0500142 print_range(old_desc_blk,
143 old_desc_blk + old_desc_blocks - 1);
Theodore Ts'o35238dd2004-12-23 13:54:28 -0500144 if (reserved_gdt) {
145 printf(_("\n Reserved GDT blocks at "));
Theodore Ts'o9b9a7802005-12-10 21:50:30 -0500146 print_range(old_desc_blk + old_desc_blocks,
147 old_desc_blk + old_desc_blocks +
148 reserved_gdt - 1);
Theodore Ts'o35238dd2004-12-23 13:54:28 -0500149 }
Theodore Ts'oef344e12003-11-21 09:02:21 -0500150 } else if (new_desc_blk) {
151 fputc(has_super ? ',' : ' ', stdout);
152 printf(_(" Group descriptor at "));
Theodore Ts'o54434922003-12-07 01:28:50 -0500153 print_number(new_desc_blk);
Theodore Ts'oef344e12003-11-21 09:02:21 -0500154 has_super++;
Theodore Ts'oa5f0bb92001-12-02 19:29:35 +0100155 }
Theodore Ts'oef344e12003-11-21 09:02:21 -0500156 if (has_super)
157 fputc('\n', stdout);
Theodore Ts'oa5f0bb92001-12-02 19:29:35 +0100158 fputs(_(" Block bitmap at "), stdout);
Theodore Ts'o54434922003-12-07 01:28:50 -0500159 print_number(fs->group_desc[i].bg_block_bitmap);
Theodore Ts'oa5f0bb92001-12-02 19:29:35 +0100160 diff = fs->group_desc[i].bg_block_bitmap - group_blk;
161 if (diff >= 0)
Theodore Ts'o4ea7bd02001-12-16 23:23:37 -0500162 printf(" (+%ld)", diff);
Theodore Ts'oa5f0bb92001-12-02 19:29:35 +0100163 fputs(_(", Inode bitmap at "), stdout);
Theodore Ts'o54434922003-12-07 01:28:50 -0500164 print_number(fs->group_desc[i].bg_inode_bitmap);
Theodore Ts'oa5f0bb92001-12-02 19:29:35 +0100165 diff = fs->group_desc[i].bg_inode_bitmap - group_blk;
166 if (diff >= 0)
Theodore Ts'o4ea7bd02001-12-16 23:23:37 -0500167 printf(" (+%ld)", diff);
Theodore Ts'oa5f0bb92001-12-02 19:29:35 +0100168 fputs(_("\n Inode table at "), stdout);
Theodore Ts'o9b9a7802005-12-10 21:50:30 -0500169 print_range(fs->group_desc[i].bg_inode_table,
170 fs->group_desc[i].bg_inode_table +
171 inode_blocks_per_group - 1);
Theodore Ts'oa5f0bb92001-12-02 19:29:35 +0100172 diff = fs->group_desc[i].bg_inode_table - group_blk;
173 if (diff > 0)
Theodore Ts'o4ea7bd02001-12-16 23:23:37 -0500174 printf(" (+%ld)", diff);
Theodore Ts'oa5f0bb92001-12-02 19:29:35 +0100175 printf (_("\n %d free blocks, %d free inodes, "
Theodore Ts'od90a23e2002-10-25 17:07:11 -0400176 "%d directories\n"),
Theodore Ts'o3839e651997-04-26 13:21:57 +0000177 fs->group_desc[i].bg_free_blocks_count,
178 fs->group_desc[i].bg_free_inodes_count,
179 fs->group_desc[i].bg_used_dirs_count);
Theodore Ts'od90a23e2002-10-25 17:07:11 -0400180 if (block_bitmap) {
181 fputs(_(" Free blocks: "), stdout);
182 print_free (i, block_bitmap,
183 fs->super->s_blocks_per_group,
184 fs->super->s_first_data_block);
185 fputc('\n', stdout);
186 block_bitmap += fs->super->s_blocks_per_group / 8;
187 }
188 if (inode_bitmap) {
189 fputs(_(" Free inodes: "), stdout);
190 print_free (i, inode_bitmap,
191 fs->super->s_inodes_per_group, 1);
192 fputc('\n', stdout);
193 inode_bitmap += fs->super->s_inodes_per_group / 8;
194 }
Theodore Ts'o521e3681997-04-29 17:48:10 +0000195 group_blk = next_blk;
Theodore Ts'o3839e651997-04-26 13:21:57 +0000196 }
197}
198
Theodore Ts'o0655b102001-12-21 23:59:46 -0500199static void list_bad_blocks(ext2_filsys fs, int dump)
Theodore Ts'o3839e651997-04-26 13:21:57 +0000200{
201 badblocks_list bb_list = 0;
202 badblocks_iterate bb_iter;
203 blk_t blk;
204 errcode_t retval;
Theodore Ts'o0655b102001-12-21 23:59:46 -0500205 const char *header, *fmt;
Theodore Ts'o3839e651997-04-26 13:21:57 +0000206
207 retval = ext2fs_read_bb_inode(fs, &bb_list);
208 if (retval) {
Theodore Ts'o9b9a7802005-12-10 21:50:30 -0500209 com_err("ext2fs_read_bb_inode", retval, 0);
Theodore Ts'o0655b102001-12-21 23:59:46 -0500210 return;
Theodore Ts'o3839e651997-04-26 13:21:57 +0000211 }
Theodore Ts'ocbbf0312001-06-13 00:12:04 +0000212 retval = ext2fs_badblocks_list_iterate_begin(bb_list, &bb_iter);
Theodore Ts'o3839e651997-04-26 13:21:57 +0000213 if (retval) {
Theodore Ts'ocbbf0312001-06-13 00:12:04 +0000214 com_err("ext2fs_badblocks_list_iterate_begin", retval,
Theodore Ts'od9c56d32000-02-08 00:47:55 +0000215 _("while printing bad block list"));
Theodore Ts'o0655b102001-12-21 23:59:46 -0500216 return;
Theodore Ts'o3839e651997-04-26 13:21:57 +0000217 }
Theodore Ts'o0655b102001-12-21 23:59:46 -0500218 if (dump) {
219 header = fmt = "%d\n";
220 } else {
221 header = _("Bad blocks: %d");
222 fmt = ", %d";
223 }
224 while (ext2fs_badblocks_list_iterate(bb_iter, &blk)) {
225 printf(header ? header : fmt, blk);
226 header = 0;
227 }
Theodore Ts'ocbbf0312001-06-13 00:12:04 +0000228 ext2fs_badblocks_list_iterate_end(bb_iter);
Theodore Ts'o0655b102001-12-21 23:59:46 -0500229 if (!dump)
230 fputc('\n', stdout);
Theodore Ts'o1e3472c1997-04-29 14:53:37 +0000231}
Theodore Ts'of3db3561997-04-26 13:34:30 +0000232
Theodore Ts'o16ed5b32001-01-16 07:47:31 +0000233static void print_journal_information(ext2_filsys fs)
234{
235 errcode_t retval;
236 char buf[1024];
237 char str[80];
Theodore Ts'o54434922003-12-07 01:28:50 -0500238 unsigned int i;
Theodore Ts'o16ed5b32001-01-16 07:47:31 +0000239 journal_superblock_t *jsb;
240
241 /* Get the journal superblock */
Theodore Ts'o02088862001-01-18 01:44:19 +0000242 if ((retval = io_channel_read_blk(fs->io, fs->super->s_first_data_block+1, -1024, buf))) {
Theodore Ts'o16ed5b32001-01-16 07:47:31 +0000243 com_err(program_name, retval,
244 _("while reading journal superblock"));
245 exit(1);
246 }
247 jsb = (journal_superblock_t *) buf;
248 if ((jsb->s_header.h_magic != (unsigned) ntohl(JFS_MAGIC_NUMBER)) ||
249 (jsb->s_header.h_blocktype !=
250 (unsigned) ntohl(JFS_SUPERBLOCK_V2))) {
251 com_err(program_name, 0,
252 _("Couldn't find journal superblock magic numbers"));
253 exit(1);
254 }
255
Takashi Sato8deb80a2006-03-18 21:43:46 -0500256 printf(_("\nJournal block size: %u\n"
257 "Journal length: %u\n"
258 "Journal first block: %u\n"
Theodore Ts'oa5f0bb92001-12-02 19:29:35 +0100259 "Journal sequence: 0x%08x\n"
Takashi Sato8deb80a2006-03-18 21:43:46 -0500260 "Journal start: %u\n"
261 "Journal number of users: %lu\n"),
Theodore Ts'oa5f0bb92001-12-02 19:29:35 +0100262 ntohl(jsb->s_blocksize), ntohl(jsb->s_maxlen),
263 ntohl(jsb->s_first), ntohl(jsb->s_sequence),
264 ntohl(jsb->s_start), ntohl(jsb->s_nr_users));
265
Theodore Ts'o16ed5b32001-01-16 07:47:31 +0000266 for (i=0; i < ntohl(jsb->s_nr_users); i++) {
Theodore Ts'o16ed5b32001-01-16 07:47:31 +0000267 uuid_unparse(&jsb->s_users[i*16], str);
Theodore Ts'oa5f0bb92001-12-02 19:29:35 +0100268 printf(i ? " %s\n"
Theodore Ts'obb145b02005-06-20 08:35:27 -0400269 : _("Journal users: %s\n"),
Theodore Ts'oa5f0bb92001-12-02 19:29:35 +0100270 str);
Theodore Ts'o16ed5b32001-01-16 07:47:31 +0000271 }
272}
273
Theodore Ts'o00e54331997-09-16 02:13:52 +0000274int main (int argc, char ** argv)
Theodore Ts'o3839e651997-04-26 13:21:57 +0000275{
276 errcode_t retval;
277 ext2_filsys fs;
Theodore Ts'of3db3561997-04-26 13:34:30 +0000278 int print_badblocks = 0;
Theodore Ts'o02e7dd91999-06-18 00:48:41 +0000279 int use_superblock = 0;
280 int use_blocksize = 0;
Theodore Ts'o348e43d2001-05-03 14:43:43 +0000281 int image_dump = 0;
Theodore Ts'o27401561999-09-14 20:11:19 +0000282 int force = 0;
Theodore Ts'o16ed5b32001-01-16 07:47:31 +0000283 int flags;
Theodore Ts'o27401561999-09-14 20:11:19 +0000284 int header_only = 0;
Theodore Ts'o1e3472c1997-04-29 14:53:37 +0000285 int big_endian;
Theodore Ts'o519149f1997-10-25 03:49:49 +0000286 int c;
Theodore Ts'o3839e651997-04-26 13:21:57 +0000287
Theodore Ts'od9c56d32000-02-08 00:47:55 +0000288#ifdef ENABLE_NLS
289 setlocale(LC_MESSAGES, "");
Theodore Ts'o14308a52002-03-05 03:26:52 -0500290 setlocale(LC_CTYPE, "");
Theodore Ts'od9c56d32000-02-08 00:47:55 +0000291 bindtextdomain(NLS_CAT_NAME, LOCALEDIR);
292 textdomain(NLS_CAT_NAME);
293#endif
Theodore Ts'o5c576471997-04-29 15:29:49 +0000294 initialize_ext2_error_table();
Theodore Ts'o0f8973f2001-08-27 12:44:23 -0400295 fprintf (stderr, "dumpe2fs %s (%s)\n", E2FSPROGS_VERSION,
296 E2FSPROGS_DATE);
Theodore Ts'o3839e651997-04-26 13:21:57 +0000297 if (argc && *argv)
298 program_name = *argv;
Theodore Ts'of3db3561997-04-26 13:34:30 +0000299
Theodore Ts'o348e43d2001-05-03 14:43:43 +0000300 while ((c = getopt (argc, argv, "bfhixVo:")) != EOF) {
Theodore Ts'of3db3561997-04-26 13:34:30 +0000301 switch (c) {
302 case 'b':
303 print_badblocks++;
304 break;
Theodore Ts'o27401561999-09-14 20:11:19 +0000305 case 'f':
306 force++;
307 break;
308 case 'h':
309 header_only++;
310 break;
Theodore Ts'o348e43d2001-05-03 14:43:43 +0000311 case 'i':
312 image_dump++;
313 break;
Theodore Ts'o02e7dd91999-06-18 00:48:41 +0000314 case 'o':
315 if (optarg[0] == 'b')
316 use_superblock = atoi(optarg+1);
317 else if (optarg[0] == 'B')
318 use_blocksize = atoi(optarg+1);
319 else
320 usage();
321 break;
Theodore Ts'o5c576471997-04-29 15:29:49 +0000322 case 'V':
323 /* Print version number and exit */
Theodore Ts'od9c56d32000-02-08 00:47:55 +0000324 fprintf(stderr, _("\tUsing %s\n"),
Theodore Ts'o5c576471997-04-29 15:29:49 +0000325 error_message(EXT2_ET_BASE));
326 exit(0);
Theodore Ts'o80c22c92000-08-14 15:32:11 +0000327 case 'x':
Theodore Ts'o9b9a7802005-12-10 21:50:30 -0500328 hex_format++;
Theodore Ts'o80c22c92000-08-14 15:32:11 +0000329 break;
Theodore Ts'of3db3561997-04-26 13:34:30 +0000330 default:
Theodore Ts'o818180c1998-06-27 05:11:14 +0000331 usage();
Theodore Ts'of3db3561997-04-26 13:34:30 +0000332 }
333 }
334 if (optind > argc - 1)
Theodore Ts'o818180c1998-06-27 05:11:14 +0000335 usage();
Theodore Ts'of3db3561997-04-26 13:34:30 +0000336 device_name = argv[optind++];
Theodore Ts'o02e7dd91999-06-18 00:48:41 +0000337 if (use_superblock && !use_blocksize)
338 use_blocksize = 1024;
Theodore Ts'o16ed5b32001-01-16 07:47:31 +0000339 flags = EXT2_FLAG_JOURNAL_DEV_OK;
340 if (force)
341 flags |= EXT2_FLAG_FORCE;
Theodore Ts'o348e43d2001-05-03 14:43:43 +0000342 if (image_dump)
343 flags |= EXT2_FLAG_IMAGE_FILE;
344
Theodore Ts'o16ed5b32001-01-16 07:47:31 +0000345 retval = ext2fs_open (device_name, flags, use_superblock,
346 use_blocksize, unix_io_manager, &fs);
Theodore Ts'of3db3561997-04-26 13:34:30 +0000347 if (retval) {
Theodore Ts'od9c56d32000-02-08 00:47:55 +0000348 com_err (program_name, retval, _("while trying to open %s"),
Theodore Ts'o3839e651997-04-26 13:21:57 +0000349 device_name);
Theodore Ts'od9c56d32000-02-08 00:47:55 +0000350 printf (_("Couldn't find valid filesystem superblock.\n"));
Theodore Ts'o3839e651997-04-26 13:21:57 +0000351 exit (1);
352 }
Theodore Ts'of3db3561997-04-26 13:34:30 +0000353 if (print_badblocks) {
Theodore Ts'o0655b102001-12-21 23:59:46 -0500354 list_bad_blocks(fs, 1);
Theodore Ts'of3db3561997-04-26 13:34:30 +0000355 } else {
Theodore Ts'o27401561999-09-14 20:11:19 +0000356 big_endian = ((fs->flags & EXT2_FLAG_SWAP_BYTES) != 0);
Theodore Ts'ocbbf0312001-06-13 00:12:04 +0000357#ifdef WORDS_BIGENDIAN
358 big_endian = !big_endian;
359#endif
Theodore Ts'o27401561999-09-14 20:11:19 +0000360 if (big_endian)
Theodore Ts'od9c56d32000-02-08 00:47:55 +0000361 printf(_("Note: This is a byte-swapped filesystem\n"));
Theodore Ts'o27401561999-09-14 20:11:19 +0000362 list_super (fs->super);
Theodore Ts'o16ed5b32001-01-16 07:47:31 +0000363 if (fs->super->s_feature_incompat &
364 EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) {
365 print_journal_information(fs);
366 ext2fs_close(fs);
367 exit(0);
368 }
Theodore Ts'o0655b102001-12-21 23:59:46 -0500369 list_bad_blocks(fs, 0);
Theodore Ts'o27401561999-09-14 20:11:19 +0000370 if (header_only) {
371 ext2fs_close (fs);
372 exit (0);
373 }
Theodore Ts'of3db3561997-04-26 13:34:30 +0000374 retval = ext2fs_read_bitmaps (fs);
Theodore Ts'of3db3561997-04-26 13:34:30 +0000375 list_desc (fs);
Theodore Ts'od90a23e2002-10-25 17:07:11 -0400376 if (retval) {
377 printf(_("\n%s: %s: error reading bitmaps: %s\n"),
378 program_name, device_name,
379 error_message(retval));
380 }
Theodore Ts'o3839e651997-04-26 13:21:57 +0000381 }
Theodore Ts'o3839e651997-04-26 13:21:57 +0000382 ext2fs_close (fs);
383 exit (0);
384}