From f222de72566dbad0c7ae9abb1bcbe2d1fd55b126 Mon Sep 17 00:00:00 2001 From: Kazuya Mio Date: Tue, 5 Dec 2017 00:15:38 +0000 Subject: [PATCH] e2freefrag: print 64bit free blocks count e2freefrag prints incorrect free blocks count when the number of free blocks is larger than 2^32. To fix this problem, e2freefrag uses ext2fs_free_blocks_count(), not fs->super->s_free_blocks_count. Signed-off-by: Kazuya Mio Signed-off-by: Theodore Ts'o --- misc/e2freefrag.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/misc/e2freefrag.c b/misc/e2freefrag.c index 90acb7e..8d805a0 100644 --- a/misc/e2freefrag.c +++ b/misc/e2freefrag.c @@ -154,9 +154,10 @@ static errcode_t get_chunk_info(ext2_filsys fs, struct chunk_info *info, scan_block_bitmap(fs, info); - fprintf(f, "Total blocks: %llu\nFree blocks: %u (%0.1f%%)\n", - ext2fs_blocks_count(fs->super), fs->super->s_free_blocks_count, - (double)fs->super->s_free_blocks_count * 100 / + fprintf(f, "Total blocks: %llu\nFree blocks: %llu (%0.1f%%)\n", + ext2fs_blocks_count(fs->super), + ext2fs_free_blocks_count(fs->super), + (double)ext2fs_free_blocks_count(fs->super) * 100 / ext2fs_blocks_count(fs->super)); if (info->chunkbytes) { @@ -200,7 +201,7 @@ static errcode_t get_chunk_info(ext2_filsys fs, struct chunk_info *info, info->histogram.fc_chunks[i], info->histogram.fc_blocks[i], (double)info->histogram.fc_blocks[i] * 100 / - fs->super->s_free_blocks_count); + ext2fs_free_blocks_count(fs->super)); } start = end; if (start == 1<<10) { -- 1.8.3.1