summaryrefslogtreecommitdiffstats
path: root/mdadm.c
diff options
context:
space:
mode:
authorNeil Brown <neilb@suse.de>2005-06-08 01:03:45 +0200
committerNeil Brown <neilb@suse.de>2005-06-08 01:03:45 +0200
commite4c4352e49e99e3eb92bdd7e212ebebe5d1e8df6 (patch)
treeecb74ab4f26b915b8a52420588ca4f57194c5e2f /mdadm.c
parentMake --zero-superblock work for version 1 superblocks. (diff)
downloadmdadm-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.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/mdadm.c b/mdadm.c
index 6c7162a7..44fd30c9 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -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) {