diff options
Diffstat (limited to 'e2fsprogs/tune2fs.c')
-rw-r--r-- | e2fsprogs/tune2fs.c | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/e2fsprogs/tune2fs.c b/e2fsprogs/tune2fs.c index d22deede2..c8dfc6927 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; | |||
54 | static time_t last_check_time; | 54 | static time_t last_check_time; |
55 | static int print_label; | 55 | static int print_label; |
56 | static int max_mount_count, mount_count, mount_flags; | 56 | static int max_mount_count, mount_count, mount_flags; |
57 | static unsigned long interval, reserved_ratio, reserved_blocks; | 57 | static unsigned long interval, reserved_blocks; |
58 | static unsigned reserved_ratio; | ||
58 | static unsigned long resgid, resuid; | 59 | static unsigned long resgid, resuid; |
59 | static unsigned short errors; | 60 | static unsigned short errors; |
60 | static int open_flag; | 61 | static int open_flag; |
@@ -410,19 +411,14 @@ static void parse_tune2fs_options(int argc, char **argv) | |||
410 | switch (c) | 411 | switch (c) |
411 | { | 412 | { |
412 | case 'c': | 413 | case 'c': |
413 | if (safe_strtoi(optarg, &max_mount_count) || max_mount_count > 16000) { | 414 | max_mount_count = xatou_range(optarg, 0, 16000); |
414 | goto MOUNTS_COUNT_ERROR; | ||
415 | } | ||
416 | if (max_mount_count == 0) | 415 | if (max_mount_count == 0) |
417 | max_mount_count = -1; | 416 | max_mount_count = -1; |
418 | c_flag = 1; | 417 | c_flag = 1; |
419 | open_flag = EXT2_FLAG_RW; | 418 | open_flag = EXT2_FLAG_RW; |
420 | break; | 419 | break; |
421 | case 'C': | 420 | case 'C': |
422 | if (safe_strtoi(optarg, &mount_count) || mount_count > 16000) { | 421 | mount_count = xatou_range(optarg, 0, 16000); |
423 | MOUNTS_COUNT_ERROR: | ||
424 | bb_error_msg_and_die("bad mounts count - %s", optarg); | ||
425 | } | ||
426 | C_flag = 1; | 422 | C_flag = 1; |
427 | open_flag = EXT2_FLAG_RW; | 423 | open_flag = EXT2_FLAG_RW; |
428 | break; | 424 | break; |
@@ -443,13 +439,14 @@ MOUNTS_COUNT_ERROR: | |||
443 | f_flag = 1; | 439 | f_flag = 1; |
444 | break; | 440 | break; |
445 | case 'g': | 441 | case 'g': |
446 | if (safe_strtoul(optarg, &resgid)) | 442 | resgid = bb_strtoul(optarg, NULL, 10); |
443 | if (errno) | ||
447 | resgid = bb_xgetgrnam(optarg); | 444 | resgid = bb_xgetgrnam(optarg); |
448 | g_flag = 1; | 445 | g_flag = 1; |
449 | open_flag = EXT2_FLAG_RW; | 446 | open_flag = EXT2_FLAG_RW; |
450 | break; | 447 | break; |
451 | case 'i': | 448 | case 'i': |
452 | interval = strtoul (optarg, &tmp, 0); | 449 | interval = strtoul(optarg, &tmp, 0); |
453 | switch (*tmp) { | 450 | switch (*tmp) { |
454 | case 's': | 451 | case 's': |
455 | tmp++; | 452 | tmp++; |
@@ -497,9 +494,7 @@ MOUNTS_COUNT_ERROR: | |||
497 | EXT2_FLAG_JOURNAL_DEV_OK; | 494 | EXT2_FLAG_JOURNAL_DEV_OK; |
498 | break; | 495 | break; |
499 | case 'm': | 496 | case 'm': |
500 | if(safe_strtoul(optarg, &reserved_ratio) || reserved_ratio > 50) { | 497 | reserved_ratio = xatou_range(optarg, 0, 50); |
501 | bb_error_msg_and_die("bad reserved block ratio - %s", optarg); | ||
502 | } | ||
503 | m_flag = 1; | 498 | m_flag = 1; |
504 | open_flag = EXT2_FLAG_RW; | 499 | open_flag = EXT2_FLAG_RW; |
505 | break; | 500 | break; |
@@ -524,9 +519,7 @@ MOUNTS_COUNT_ERROR: | |||
524 | open_flag = EXT2_FLAG_RW; | 519 | open_flag = EXT2_FLAG_RW; |
525 | break; | 520 | break; |
526 | case 'r': | 521 | case 'r': |
527 | if(safe_strtoul(optarg, &reserved_blocks)) { | 522 | reserved_blocks = xatoul(optarg); |
528 | bb_error_msg_and_die("bad reserved blocks count - %s", optarg); | ||
529 | } | ||
530 | r_flag = 1; | 523 | r_flag = 1; |
531 | open_flag = EXT2_FLAG_RW; | 524 | open_flag = EXT2_FLAG_RW; |
532 | break; | 525 | break; |
@@ -540,7 +533,8 @@ MOUNTS_COUNT_ERROR: | |||
540 | open_flag = EXT2_FLAG_RW; | 533 | open_flag = EXT2_FLAG_RW; |
541 | break; | 534 | break; |
542 | case 'u': | 535 | case 'u': |
543 | if (safe_strtoul(optarg, &resuid)) | 536 | resuid = bb_strtoul(optarg, NULL, 10); |
537 | if (errno) | ||
544 | resuid = bb_xgetpwnam(optarg); | 538 | resuid = bb_xgetpwnam(optarg); |
545 | u_flag = 1; | 539 | u_flag = 1; |
546 | open_flag = EXT2_FLAG_RW; | 540 | open_flag = EXT2_FLAG_RW; |
@@ -646,9 +640,9 @@ int tune2fs_main(int argc, char **argv) | |||
646 | } | 640 | } |
647 | if (m_flag) { | 641 | if (m_flag) { |
648 | sb->s_r_blocks_count = (sb->s_blocks_count / 100) | 642 | sb->s_r_blocks_count = (sb->s_blocks_count / 100) |
649 | * reserved_ratio; | 643 | * reserved_ratio; |
650 | ext2fs_mark_super_dirty(fs); | 644 | ext2fs_mark_super_dirty(fs); |
651 | printf("Setting reserved blocks percentage to %lu (%u blocks)\n", | 645 | printf("Setting reserved blocks percentage to %u (%u blocks)\n", |
652 | reserved_ratio, sb->s_r_blocks_count); | 646 | reserved_ratio, sb->s_r_blocks_count); |
653 | } | 647 | } |
654 | if (r_flag) { | 648 | if (r_flag) { |