diff options
author | Neil Brown <neilb@suse.de> | 2005-06-08 01:03:45 +0200 |
---|---|---|
committer | Neil Brown <neilb@suse.de> | 2005-06-08 01:03:45 +0200 |
commit | e4c4352e49e99e3eb92bdd7e212ebebe5d1e8df6 (patch) | |
tree | ecb74ab4f26b915b8a52420588ca4f57194c5e2f /mdadm.c | |
parent | Make --zero-superblock work for version 1 superblocks. (diff) | |
download | mdadm-e4c4352e49e99e3eb92bdd7e212ebebe5d1e8df6.tar.xz mdadm-e4c4352e49e99e3eb92bdd7e212ebebe5d1e8df6.zip |
Move the test for validity of raid_disk later.
This allows the check to be done after we know what
metadata format is being used, and so the max number of raiddisks
is known.
Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
Diffstat (limited to 'mdadm.c')
-rw-r--r-- | mdadm.c | 30 |
1 files changed, 22 insertions, 8 deletions
@@ -427,17 +427,11 @@ int main(int argc, char *argv[]) exit(2); } raiddisks = strtol(optarg, &c, 10); - if (!optarg[0] || *c || raiddisks<=0 || raiddisks > max_disks) { + if (!optarg[0] || *c || raiddisks<=0) { fprintf(stderr, Name ": invalid number of raid devices: %s\n", optarg); exit(2); } - if (raiddisks == 1 && !force && level != -5) { - fprintf(stderr, Name ": '1' is an unusual number of drives for an array, so it is probably\n" - " a mistake. If you really mean it you will need to specify --force before\n" - " setting the number of drives.\n"); - exit(2); - } ident.raid_disks = raiddisks; continue; @@ -453,7 +447,7 @@ int main(int argc, char *argv[]) exit(2); } sparedisks = strtol(optarg, &c, 10); - if (!optarg[0] || *c || sparedisks < 0 || sparedisks > max_disks - raiddisks) { + if (!optarg[0] || *c || sparedisks < 0) { fprintf(stderr, Name ": invalid number of spare-devices: %s\n", optarg); exit(2); @@ -782,6 +776,26 @@ int main(int argc, char *argv[]) } } + if (raiddisks) { + if (raiddisks > max_disks) { + fprintf(stderr, Name ": invalid number of raid devices: %s\n", + optarg); + exit(2); + } + if (raiddisks == 1 && !force && level != -5) { + fprintf(stderr, Name ": '1' is an unusual number of drives for an array, so it is probably\n" + " a mistake. If you really mean it you will need to specify --force before\n" + " setting the number of drives.\n"); + exit(2); + } + } + if (sparedisks) { + if ( sparedisks > max_disks - raiddisks) { + fprintf(stderr, Name ": invalid number of spare-devices: %s\n", + optarg); + exit(2); + } + } rv = 0; switch(mode) { |