Spit out just the group descriptor data in a machine readable format.
This is most useful for testing and scripting purposes.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
.SH SYNOPSIS
.B dumpe2fs
[
-.B \-bfhixV
+.B \-bfghixV
]
[
.B \-o superblock=\fIsuperblock
force dumpe2fs to display a filesystem even though it may have some
filesystem feature flags which dumpe2fs may not understand (and which
can cause some of dumpe2fs's display to be suspect).
+.TP
+.B \-g
+display the group descriptor information in a machine readable colon-separated
+value format. The fields displayed are the group number; the number of the
+first block in the group; the superblock location (or -1 if not present); the
+range of blocks used by the group descriptors (or -1 if not present); the block
+bitmap location; the inode bitmap location; and the range of blocks used by the
+inode table.
.TP
.B \-h
only display the superblock information and not any of the block
static void usage(void)
{
- fprintf (stderr, _("Usage: %s [-bfhixV] [-o superblock=<num>] "
+ fprintf(stderr, _("Usage: %s [-bfghixV] [-o superblock=<num>] "
"[-o blocksize=<num>] device\n"), program_name);
- exit (1);
+ exit(1);
}
static void print_number(unsigned long long num)
}
}
-static void list_desc (ext2_filsys fs)
+static void list_desc(ext2_filsys fs, int grp_only)
{
unsigned long i;
blk64_t first_block, last_block;
old_desc_blocks = fs->super->s_first_meta_bg;
else
old_desc_blocks = fs->desc_blocks;
+ if (grp_only)
+ printf("group:block:super:gdt:bbitmap:ibitmap:itable\n");
for (i = 0; i < fs->group_desc_count; i++) {
first_block = ext2fs_group_first_block2(fs, i);
last_block = ext2fs_group_last_block2(fs, i);
ext2fs_super_and_bgd_loc2(fs, i, &super_blk,
&old_desc_blk, &new_desc_blk, 0);
+ if (grp_only) {
+ printf("%lu:%llu:", i, first_block);
+ if (i == 0 || super_blk)
+ printf("%llu:", super_blk);
+ else
+ printf("-1:");
+ if (old_desc_blk) {
+ print_range(old_desc_blk,
+ old_desc_blk + old_desc_blocks - 1);
+ printf(":");
+ } else if (new_desc_blk)
+ printf("%llu:", new_desc_blk);
+ else
+ printf("-1:");
+ printf("%llu:%llu:%llu\n",
+ ext2fs_block_bitmap_loc(fs, i),
+ ext2fs_inode_bitmap_loc(fs, i),
+ ext2fs_inode_table_loc(fs, i));
+ continue;
+ }
+
printf (_("Group %lu: (Blocks "), i);
print_range(first_block, last_block);
fputs(")", stdout);
int flags;
int header_only = 0;
int c;
+ int grp_only = 0;
#ifdef ENABLE_NLS
setlocale(LC_MESSAGES, "");
if (argc && *argv)
program_name = *argv;
- while ((c = getopt (argc, argv, "bfhixVo:")) != EOF) {
+ while ((c = getopt(argc, argv, "bfghixVo:")) != EOF) {
switch (c) {
case 'b':
print_badblocks++;
case 'f':
force++;
break;
+ case 'g':
+ grp_only++;
+ break;
case 'h':
header_only++;
break;
if (print_badblocks) {
list_bad_blocks(fs, 1);
} else {
+ if (grp_only)
+ goto just_descriptors;
list_super (fs->super);
if (fs->super->s_feature_incompat &
EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) {
}
if (!retval && (fs->flags & EXT2_FLAG_IGNORE_CSUM_ERRORS))
printf("%s", _("\n*** Checksum errors detected in bitmaps! Run e2fsck now!\n\n"));
- list_desc (fs);
+just_descriptors:
+ list_desc(fs, grp_only);
if (retval) {
printf(_("\n%s: %s: error reading bitmaps: %s\n"),
program_name, device_name,
--- /dev/null
+Creating filesystem with 1048576 4k blocks and 262144 inodes
+Superblock backups stored on blocks:
+ 32768, 98304, 163840, 229376, 294912, 819200, 884736
+
+Allocating group tables: \b\b\b\b\bdone
+Writing inode tables: \b\b\b\b\bdone
+Creating journal (32768 blocks): done
+Writing superblocks and filesystem accounting information: \b\b\b\b\bdone
+
+Pass 1: Checking inodes, blocks, and sizes
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+test_filesys: 11/262144 files (0.0% non-contiguous), 51278/1048576 blocks
+Exit status is 0
+dumpe2fs output
+
+group:block:super:gdt:bbitmap:ibitmap:itable
+0:0:0:1-1:257:273:289
+1:32768:32768:32769-32769:258:274:801
+2:65536:-1:-1:259:275:1313
+3:98304:98304:98305-98305:260:276:1825
+4:131072:-1:-1:261:277:2337
+5:163840:163840:163841-163841:262:278:2849
+6:196608:-1:-1:263:279:3361
+7:229376:229376:229377-229377:264:280:3873
+8:262144:-1:-1:265:281:4385
+9:294912:294912:294913-294913:266:282:4897
+10:327680:-1:-1:267:283:5409
+11:360448:-1:-1:268:284:5921
+12:393216:-1:-1:269:285:6433
+13:425984:-1:-1:270:286:6945
+14:458752:-1:-1:271:287:7457
+15:491520:-1:-1:272:288:7969
+16:524288:-1:-1:524288:524304:524320
+17:557056:-1:-1:524289:524305:524832
+18:589824:-1:-1:524290:524306:525344
+19:622592:-1:-1:524291:524307:525856
+20:655360:-1:-1:524292:524308:526368
+21:688128:-1:-1:524293:524309:526880
+22:720896:-1:-1:524294:524310:527392
+23:753664:-1:-1:524295:524311:527904
+24:786432:-1:-1:524296:524312:528416
+25:819200:819200:819201-819201:524297:524313:528928
+26:851968:-1:-1:524298:524314:529440
+27:884736:884736:884737-884737:524299:524315:529952
+28:917504:-1:-1:524300:524316:530464
+29:950272:-1:-1:524301:524317:530976
+30:983040:-1:-1:524302:524318:531488
+31:1015808:-1:-1:524303:524319:532000
--- /dev/null
+dumpe2fs group only mode
--- /dev/null
+if test -x $DEBUGFS_EXE; then
+
+FSCK_OPT=-fy
+OUT=$test_name.log
+if [ -f $test_dir/expect.gz ]; then
+ EXP=$test_name.tmp
+ gunzip < $test_dir/expect.gz > $EXP1
+else
+ EXP=$test_dir/expect
+fi
+
+cp /dev/null $OUT
+
+$MKE2FS -F -o Linux -b 4096 -O has_journal -T ext4 $TMPFILE 1048576 2>&1 | sed -f $cmd_dir/filter.sed >> $OUT 2>&1
+
+$FSCK -fy -N test_filesys $TMPFILE > $OUT.new 2>&1
+status=$?
+echo Exit status is $status >> $OUT.new
+sed -f $cmd_dir/filter.sed -e "s;$TMPFILE;test.img;" $OUT.new >> $OUT
+rm -f $OUT.new
+
+echo "dumpe2fs output" >> $OUT
+$DUMPE2FS -g $TMPFILE 2>&1 | sed -f $cmd_dir/filter.sed >> $OUT
+
+rm -f $TMPFILE
+
+cmp -s $OUT $EXP
+status=$?
+
+if [ "$status" = 0 ] ; then
+ echo "$test_name: $test_description: ok"
+ touch $test_name.ok
+else
+ echo "$test_name: $test_description: failed"
+ diff $DIFF_OPTS $EXP $OUT > $test_name.failed
+ rm -f $test_name.tmp
+fi
+
+unset IMAGE FSCK_OPT OUT EXP
+
+else #if test -x $DEBUGFS_EXE; then
+ echo "$test_name: $test_description: skipped"
+fi