mdadm/Build:check the level parameter when build new array

check if user forgets to specify the --level
when build a new array. such as:
./mdadm -B /dev/md0 -n2 /dev/loop[0-1]

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
This commit is contained in:
Zhilong Liu 2017-03-28 21:52:27 +08:00 committed by Jes Sorensen
parent 2dd271fe70
commit 1b4944f3a1
1 changed files with 4 additions and 0 deletions

View File

@ -56,6 +56,10 @@ int Build(char *mddev, struct mddev_dev *devlist,
int uuid[4] = {0,0,0,0};
struct map_ent *map = NULL;
if (s->level == UnSet) {
pr_err("a RAID level is needed to Build an array.\n");
return 1;
}
/* scan all devices, make sure they really are block devices */
for (dv = devlist; dv; dv=dv->next) {
subdevs++;