From ce911145ed0fdd1918ee0c80d407c3e778dc64ee Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Wed, 6 Jul 2005 11:50:08 -0500 Subject: [PATCH] Allow fractional percentages to the -m option in mke2fs and tune2fs Allow the reserved blocks ratio to be specified in fractional percentages. Addresses-Debian-Bug: #80205 Signed-off-by: Andreas Dilger --- misc/ChangeLog | 6 ++++++ misc/mke2fs.c | 4 ++-- misc/tune2fs.c | 10 +++++----- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/misc/ChangeLog b/misc/ChangeLog index c2a5a2a..17d69fc 100644 --- a/misc/ChangeLog +++ b/misc/ChangeLog @@ -1,3 +1,9 @@ +2005-07-05 Theodore Ts'o + + * tune2fs.c, mke2fs.c: Allow fractional percentages when + specifying the reserved ratio. (Addresses Debian Bug + #80205). + 2006-06-30 Theodore Ts'o * Release of E2fsprogs 1.38 diff --git a/misc/mke2fs.c b/misc/mke2fs.c index 2379ddc..d50733e 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -900,7 +900,7 @@ static void PRS(int argc, char *argv[]) int blocksize = 0; int inode_ratio = 0; int inode_size = 0; - int reserved_ratio = 5; + double reserved_ratio = 5.0; int sector_size = 0; int show_version_only = 0; ext2_ino_t num_inodes = 0; @@ -1058,7 +1058,7 @@ static void PRS(int argc, char *argv[]) strcpy(bad_blocks_filename, optarg); break; case 'm': - reserved_ratio = strtoul(optarg, &tmp, 0); + reserved_ratio = strtod(optarg, &tmp); if (reserved_ratio > 50 || *tmp) { com_err(program_name, 0, _("invalid reserved blocks percent - %s"), diff --git a/misc/tune2fs.c b/misc/tune2fs.c index 15bfd44..adf0b56 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -64,7 +64,8 @@ static int m_flag, M_flag, r_flag, s_flag = -1, u_flag, U_flag, T_flag; static time_t last_check_time; static int print_label; static int max_mount_count, mount_count, mount_flags; -static unsigned long interval, reserved_ratio, reserved_blocks; +static unsigned long interval, reserved_blocks; +static double reserved_ratio; static unsigned long resgid, resuid; static unsigned short errors; static int open_flag; @@ -621,7 +622,7 @@ static void parse_tune2fs_options(int argc, char **argv) EXT2_FLAG_JOURNAL_DEV_OK; break; case 'm': - reserved_ratio = strtoul (optarg, &tmp, 0); + reserved_ratio = strtod(optarg, &tmp); if (*tmp || reserved_ratio > 50) { com_err (program_name, 0, _("bad reserved block ratio - %s"), @@ -822,10 +823,9 @@ int main (int argc, char ** argv) printf (_("Setting interval between checks to %lu seconds\n"), interval); } if (m_flag) { - sb->s_r_blocks_count = (sb->s_blocks_count / 100) - * reserved_ratio; + sb->s_r_blocks_count = sb->s_blocks_count * reserved_ratio /100; ext2fs_mark_super_dirty(fs); - printf (_("Setting reserved blocks percentage to %lu (%u blocks)\n"), + printf (_("Setting reserved blocks percentage to %g%% (%u blocks)\n"), reserved_ratio, sb->s_r_blocks_count); } if (r_flag) { -- 1.8.3.1