From 2418dfd7b934ee6bf3dc9a0aa4ffee8b37f4384f Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Fri, 16 Sep 2011 10:13:41 -0400 Subject: [PATCH] dumpe2fs: display "free blocks" as "free clusters" for bigalloc file systems Change this for the equivalent function in debugfs as well. Signed-off-by: "Theodore Ts'o" --- debugfs/debugfs.c | 11 ++++++++--- misc/dumpe2fs.c | 9 +++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c index e7d74363..4b29260a 100644 --- a/debugfs/debugfs.c +++ b/debugfs/debugfs.c @@ -308,6 +308,7 @@ static void print_bg_opts(ext2_filsys fs, dgrp_t group, int mask, void do_show_super_stats(int argc, char *argv[]) { + const char *units ="block"; dgrp_t i; FILE *out; int c, header_only = 0; @@ -330,6 +331,10 @@ void do_show_super_stats(int argc, char *argv[]) return; out = open_pager(); + if (EXT2_HAS_RO_COMPAT_FEATURE(current_fs->super, + EXT4_FEATURE_RO_COMPAT_BIGALLOC)) + units = "cluster"; + list_super2(current_fs->super, out); for (i=0; i < current_fs->group_desc_count; i++) numdirs += ext2fs_bg_used_dirs_count(current_fs, i); @@ -346,15 +351,15 @@ void do_show_super_stats(int argc, char *argv[]) fprintf(out, " Group %2d: block bitmap at %llu, " "inode bitmap at %llu, " "inode table at %llu\n" - " %u free %s, " + " %u free %s%s, " "%u free %s, " "%u used %s%s", i, ext2fs_block_bitmap_loc(current_fs, i), ext2fs_inode_bitmap_loc(current_fs, i), ext2fs_inode_table_loc(current_fs, i), - ext2fs_bg_free_blocks_count(current_fs, i), + ext2fs_bg_free_blocks_count(current_fs, i), units, ext2fs_bg_free_blocks_count(current_fs, i) != 1 ? - "blocks" : "block", + "s" : "", ext2fs_bg_free_inodes_count(current_fs, i), ext2fs_bg_free_inodes_count(current_fs, i) != 1 ? "inodes" : "inode", diff --git a/misc/dumpe2fs.c b/misc/dumpe2fs.c index 9a0dd46b..4d2d5c7d 100644 --- a/misc/dumpe2fs.c +++ b/misc/dumpe2fs.c @@ -148,12 +148,17 @@ static void list_desc (ext2_filsys fs) blk64_t first_block, last_block; blk64_t super_blk, old_desc_blk, new_desc_blk; char *block_bitmap=NULL, *inode_bitmap=NULL; + const char *units = _("blocks"); int inode_blocks_per_group, old_desc_blocks, reserved_gdt; int block_nbytes, inode_nbytes; int has_super; blk64_t blk_itr = EXT2FS_B2C(fs, fs->super->s_first_data_block); ext2_ino_t ino_itr = 1; + if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super, + EXT4_FEATURE_RO_COMPAT_BIGALLOC)) + units = _("clusters"); + block_nbytes = EXT2_CLUSTERS_PER_GROUP(fs->super) / 8; inode_nbytes = EXT2_INODES_PER_GROUP(fs->super) / 8; @@ -226,9 +231,9 @@ static void list_desc (ext2_filsys fs) inode_blocks_per_group - 1); print_bg_rel_offset(fs, ext2fs_inode_table_loc(fs, i), 1, first_block, last_block); - printf (_("\n %u free blocks, %u free inodes, " + printf (_("\n %u free %s, %u free inodes, " "%u directories%s"), - ext2fs_bg_free_blocks_count(fs, i), + ext2fs_bg_free_blocks_count(fs, i), units, ext2fs_bg_free_inodes_count(fs, i), ext2fs_bg_used_dirs_count(fs, i), ext2fs_bg_itable_unused(fs, i) ? "" : "\n"); -- 2.11.0