Whamcloud - gitweb
Allow fractional percentages to the -m option in mke2fs and tune2fs
authorAndreas Dilger <adilger@clusterfs.com>
Wed, 6 Jul 2005 16:50:08 +0000 (11:50 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 6 Jul 2005 16:50:08 +0000 (11:50 -0500)
Allow the reserved blocks ratio to be specified in fractional
percentages.

Addresses-Debian-Bug: #80205
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
misc/ChangeLog
misc/mke2fs.c
misc/tune2fs.c

index c2a5a2a..17d69fc 100644 (file)
@@ -1,3 +1,9 @@
+2005-07-05  Theodore Ts'o  <tytso@mit.edu>
+
+       * tune2fs.c, mke2fs.c: Allow fractional percentages when
+               specifying the reserved ratio.  (Addresses Debian Bug
+               #80205).
+
 2006-06-30  Theodore Ts'o  <tytso@mit.edu>
 
        * Release of E2fsprogs 1.38
index 2379ddc..d50733e 100644 (file)
@@ -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"),
index 15bfd44..adf0b56 100644 (file)
@@ -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) {