diff options
Diffstat (limited to 'e2fsprogs/mke2fs.c')
-rw-r--r-- | e2fsprogs/mke2fs.c | 54 |
1 files changed, 14 insertions, 40 deletions
diff --git a/e2fsprogs/mke2fs.c b/e2fsprogs/mke2fs.c index 1c4f1541e..f25ecfb6c 100644 --- a/e2fsprogs/mke2fs.c +++ b/e2fsprogs/mke2fs.c | |||
@@ -673,7 +673,7 @@ static void show_stats(ext2_filsys fs) | |||
673 | static int set_os(struct ext2_super_block *sb, char *os) | 673 | static int set_os(struct ext2_super_block *sb, char *os) |
674 | { | 674 | { |
675 | if (isdigit (*os)) { | 675 | if (isdigit (*os)) { |
676 | sb->s_creator_os = atoi (os); | 676 | sb->s_creator_os = atoi(os); |
677 | return 1; | 677 | return 1; |
678 | } | 678 | } |
679 | 679 | ||
@@ -790,7 +790,7 @@ static __u32 ok_features[3] = { | |||
790 | 790 | ||
791 | static int PRS(int argc, char *argv[]) | 791 | static int PRS(int argc, char *argv[]) |
792 | { | 792 | { |
793 | int b, c; | 793 | int c; |
794 | int size; | 794 | int size; |
795 | char * tmp; | 795 | char * tmp; |
796 | int blocksize = 0; | 796 | int blocksize = 0; |
@@ -848,54 +848,32 @@ static int PRS(int argc, char *argv[]) | |||
848 | "b:cE:f:g:i:jl:m:no:qr:R:s:tvI:J:ST:FL:M:N:O:V")) != EOF) { | 848 | "b:cE:f:g:i:jl:m:no:qr:R:s:tvI:J:ST:FL:M:N:O:V")) != EOF) { |
849 | switch (c) { | 849 | switch (c) { |
850 | case 'b': | 850 | case 'b': |
851 | if (safe_strtoi(optarg, &blocksize)) | 851 | blocksize = xatou_range(optarg, EXT2_MIN_BLOCK_SIZE, EXT2_MAX_BLOCK_SIZE); |
852 | goto BLOCKSIZE_ERROR; | ||
853 | b = (blocksize > 0) ? blocksize : -blocksize; | ||
854 | if (b < EXT2_MIN_BLOCK_SIZE || | ||
855 | b > EXT2_MAX_BLOCK_SIZE) { | ||
856 | BLOCKSIZE_ERROR: | ||
857 | bb_error_msg_and_die("invalid block size - %s", optarg); | ||
858 | } | ||
859 | mke2fs_warning_msg((blocksize > 4096), | 852 | mke2fs_warning_msg((blocksize > 4096), |
860 | "blocksize %d not usable on most systems", | 853 | "blocksize %d not usable on most systems", |
861 | blocksize); | 854 | blocksize); |
862 | if (blocksize > 0) | 855 | param.s_log_block_size = |
863 | param.s_log_block_size = | 856 | int_log2(blocksize >> EXT2_MIN_BLOCK_LOG_SIZE); |
864 | int_log2(blocksize >> | ||
865 | EXT2_MIN_BLOCK_LOG_SIZE); | ||
866 | break; | 857 | break; |
867 | case 'c': /* Check for bad blocks */ | 858 | case 'c': /* Check for bad blocks */ |
868 | case 't': /* deprecated */ | 859 | case 't': /* deprecated */ |
869 | cflag++; | 860 | cflag++; |
870 | break; | 861 | break; |
871 | case 'f': | 862 | case 'f': |
872 | if (safe_strtoi(optarg, &size) || size < EXT2_MIN_BLOCK_SIZE || size > EXT2_MAX_BLOCK_SIZE ){ | 863 | size = xatou_range(optarg, EXT2_MIN_BLOCK_SIZE, EXT2_MAX_BLOCK_SIZE); |
873 | bb_error_msg_and_die("invalid fragment size - %s", optarg); | ||
874 | } | ||
875 | param.s_log_frag_size = | 864 | param.s_log_frag_size = |
876 | int_log2(size >> EXT2_MIN_BLOCK_LOG_SIZE); | 865 | int_log2(size >> EXT2_MIN_BLOCK_LOG_SIZE); |
877 | mke2fs_warning_msg(1, "fragments not supported. Ignoring -f option"); | 866 | mke2fs_warning_msg(1, "fragments not supported. Ignoring -f option"); |
878 | break; | 867 | break; |
879 | case 'g': | 868 | case 'g': |
880 | { | 869 | param.s_blocks_per_group = xatou32(optarg); |
881 | int foo; | ||
882 | if (safe_strtoi(optarg, &foo)) { | ||
883 | bb_error_msg_and_die("Illegal number for blocks per group"); | ||
884 | } | ||
885 | param.s_blocks_per_group = foo; | ||
886 | } | ||
887 | if ((param.s_blocks_per_group % 8) != 0) { | 870 | if ((param.s_blocks_per_group % 8) != 0) { |
888 | bb_error_msg_and_die("blocks per group must be multiple of 8"); | 871 | bb_error_msg_and_die("blocks per group must be multiple of 8"); |
889 | } | 872 | } |
890 | break; | 873 | break; |
891 | case 'i': | 874 | case 'i': |
892 | if (safe_strtoi(optarg, &inode_ratio) | 875 | /* Huh? is "* 1024" correct? */ |
893 | || inode_ratio < EXT2_MIN_BLOCK_SIZE | 876 | inode_ratio = xatou_range(optarg, EXT2_MIN_BLOCK_SIZE, EXT2_MAX_BLOCK_SIZE * 1024); |
894 | || inode_ratio > EXT2_MAX_BLOCK_SIZE * 1024) { | ||
895 | bb_error_msg_and_die("invalid inode ratio %s (min %d/max %d)", | ||
896 | optarg, EXT2_MIN_BLOCK_SIZE, | ||
897 | EXT2_MAX_BLOCK_SIZE); | ||
898 | } | ||
899 | break; | 877 | break; |
900 | case 'J': | 878 | case 'J': |
901 | parse_journal_opts(&journal_device, &journal_flags, &journal_size, optarg); | 879 | parse_journal_opts(&journal_device, &journal_flags, &journal_size, optarg); |
@@ -910,9 +888,7 @@ BLOCKSIZE_ERROR: | |||
910 | bad_blocks_filename = optarg; | 888 | bad_blocks_filename = optarg; |
911 | break; | 889 | break; |
912 | case 'm': | 890 | case 'm': |
913 | if (safe_strtoi(optarg, &reserved_ratio) || reserved_ratio > 50 ) { | 891 | reserved_ratio = xatou_range(optarg, 0, 50); |
914 | bb_error_msg_and_die("invalid reserved blocks percent - %s", optarg); | ||
915 | } | ||
916 | break; | 892 | break; |
917 | case 'n': | 893 | case 'n': |
918 | noaction++; | 894 | noaction++; |
@@ -921,7 +897,7 @@ BLOCKSIZE_ERROR: | |||
921 | creator_os = optarg; | 897 | creator_os = optarg; |
922 | break; | 898 | break; |
923 | case 'r': | 899 | case 'r': |
924 | param.s_rev_level = atoi(optarg); | 900 | param.s_rev_level = xatoi_u(optarg); |
925 | if (param.s_rev_level == EXT2_GOOD_OLD_REV) { | 901 | if (param.s_rev_level == EXT2_GOOD_OLD_REV) { |
926 | param.s_feature_incompat = 0; | 902 | param.s_feature_incompat = 0; |
927 | param.s_feature_compat = 0; | 903 | param.s_feature_compat = 0; |
@@ -929,7 +905,7 @@ BLOCKSIZE_ERROR: | |||
929 | } | 905 | } |
930 | break; | 906 | break; |
931 | case 's': /* deprecated */ | 907 | case 's': /* deprecated */ |
932 | if (atoi(optarg)) | 908 | if (xatou(optarg)) |
933 | param.s_feature_ro_compat |= | 909 | param.s_feature_ro_compat |= |
934 | EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER; | 910 | EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER; |
935 | else | 911 | else |
@@ -938,13 +914,11 @@ BLOCKSIZE_ERROR: | |||
938 | break; | 914 | break; |
939 | #ifdef EXT2_DYNAMIC_REV | 915 | #ifdef EXT2_DYNAMIC_REV |
940 | case 'I': | 916 | case 'I': |
941 | if (safe_strtoi(optarg, &inode_size)) { | 917 | inode_size = xatoi_u(optarg); |
942 | bb_error_msg_and_die("invalid inode size - %s", optarg); | ||
943 | } | ||
944 | break; | 918 | break; |
945 | #endif | 919 | #endif |
946 | case 'N': | 920 | case 'N': |
947 | num_inodes = atoi(optarg); | 921 | num_inodes = xatoi_u(optarg); |
948 | break; | 922 | break; |
949 | case 'v': | 923 | case 'v': |
950 | quiet = 0; | 924 | quiet = 0; |