From 9ff8ece57d46a9419fc60057547810824881bb45 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Tue, 17 Jun 2008 19:58:29 -0400 Subject: mke2fs, tune2fs, resize2fs: Use floating point to calculate percentages When calculating the number reserved blocks, use floating point for better accuracy, since for big filesystems it really makes a difference. In addition, mke2fs and tune2fs accepts a floating point number from the user, so they should provide that level of accuracy. Addresses-Debian-Bug: #452639 Signed-off-by: "Theodore Ts'o" --- misc/mke2fs.c | 4 ++-- misc/tune2fs.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'misc') diff --git a/misc/mke2fs.c b/misc/mke2fs.c index cf5e918e..10ac7820 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -1562,8 +1562,8 @@ static void PRS(int argc, char *argv[]) /* * Calculate number of blocks to reserve */ - fs_param.s_r_blocks_count = e2p_percent(reserved_ratio, - fs_param.s_blocks_count); + fs_param.s_r_blocks_count = (unsigned int) (reserved_ratio * + fs_param.s_blocks_count / 100.0); } int main (int argc, char *argv[]) diff --git a/misc/tune2fs.c b/misc/tune2fs.c index 4e731f5c..4c8a8342 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -973,8 +973,8 @@ int main (int argc, char ** argv) printf (_("Setting interval between checks to %lu seconds\n"), interval); } if (m_flag) { - sb->s_r_blocks_count = e2p_percent(reserved_ratio, - sb->s_blocks_count); + sb->s_r_blocks_count = (unsigned int) (reserved_ratio * + sb->s_blocks_count / 100.0); ext2fs_mark_super_dirty(fs); printf (_("Setting reserved blocks percentage to %g%% (%u blocks)\n"), reserved_ratio, sb->s_r_blocks_count); -- cgit v1.2.3