summaryrefslogtreecommitdiff
path: root/e2fsprogs/tune2fs.c
diff options
context:
space:
mode:
Diffstat (limited to 'e2fsprogs/tune2fs.c')
-rw-r--r--e2fsprogs/tune2fs.c32
1 files changed, 13 insertions, 19 deletions
diff --git a/e2fsprogs/tune2fs.c b/e2fsprogs/tune2fs.c
index d22deed..c8dfc69 100644
--- a/e2fsprogs/tune2fs.c
+++ b/e2fsprogs/tune2fs.c
@@ -54,7 +54,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 unsigned reserved_ratio;
static unsigned long resgid, resuid;
static unsigned short errors;
static int open_flag;
@@ -410,19 +411,14 @@ static void parse_tune2fs_options(int argc, char **argv)
switch (c)
{
case 'c':
- if (safe_strtoi(optarg, &max_mount_count) || max_mount_count > 16000) {
- goto MOUNTS_COUNT_ERROR;
- }
+ max_mount_count = xatou_range(optarg, 0, 16000);
if (max_mount_count == 0)
max_mount_count = -1;
c_flag = 1;
open_flag = EXT2_FLAG_RW;
break;
case 'C':
- if (safe_strtoi(optarg, &mount_count) || mount_count > 16000) {
-MOUNTS_COUNT_ERROR:
- bb_error_msg_and_die("bad mounts count - %s", optarg);
- }
+ mount_count = xatou_range(optarg, 0, 16000);
C_flag = 1;
open_flag = EXT2_FLAG_RW;
break;
@@ -443,13 +439,14 @@ MOUNTS_COUNT_ERROR:
f_flag = 1;
break;
case 'g':
- if (safe_strtoul(optarg, &resgid))
+ resgid = bb_strtoul(optarg, NULL, 10);
+ if (errno)
resgid = bb_xgetgrnam(optarg);
g_flag = 1;
open_flag = EXT2_FLAG_RW;
break;
case 'i':
- interval = strtoul (optarg, &tmp, 0);
+ interval = strtoul(optarg, &tmp, 0);
switch (*tmp) {
case 's':
tmp++;
@@ -497,9 +494,7 @@ MOUNTS_COUNT_ERROR:
EXT2_FLAG_JOURNAL_DEV_OK;
break;
case 'm':
- if(safe_strtoul(optarg, &reserved_ratio) || reserved_ratio > 50) {
- bb_error_msg_and_die("bad reserved block ratio - %s", optarg);
- }
+ reserved_ratio = xatou_range(optarg, 0, 50);
m_flag = 1;
open_flag = EXT2_FLAG_RW;
break;
@@ -524,9 +519,7 @@ MOUNTS_COUNT_ERROR:
open_flag = EXT2_FLAG_RW;
break;
case 'r':
- if(safe_strtoul(optarg, &reserved_blocks)) {
- bb_error_msg_and_die("bad reserved blocks count - %s", optarg);
- }
+ reserved_blocks = xatoul(optarg);
r_flag = 1;
open_flag = EXT2_FLAG_RW;
break;
@@ -540,7 +533,8 @@ MOUNTS_COUNT_ERROR:
open_flag = EXT2_FLAG_RW;
break;
case 'u':
- if (safe_strtoul(optarg, &resuid))
+ resuid = bb_strtoul(optarg, NULL, 10);
+ if (errno)
resuid = bb_xgetpwnam(optarg);
u_flag = 1;
open_flag = EXT2_FLAG_RW;
@@ -646,9 +640,9 @@ int tune2fs_main(int argc, char **argv)
}
if (m_flag) {
sb->s_r_blocks_count = (sb->s_blocks_count / 100)
- * reserved_ratio;
+ * reserved_ratio;
ext2fs_mark_super_dirty(fs);
- printf("Setting reserved blocks percentage to %lu (%u blocks)\n",
+ printf("Setting reserved blocks percentage to %u (%u blocks)\n",
reserved_ratio, sb->s_r_blocks_count);
}
if (r_flag) {