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 <k-mio@xxxxxxxxxxxxx> --- misc/e2freefrag.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/misc/e2freefrag.c b/misc/e2freefrag.c index b315263..c5aeab9 100644 --- a/misc/e2freefrag.c +++ b/misc/e2freefrag.c @@ -255,9 +255,10 @@ static errcode_t dump_chunk_info(ext2_filsys fs, struct chunk_info *info, unsigned long start = 0, end; int i, retval = 0; - 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) { @@ -301,7 +302,7 @@ static errcode_t dump_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) {