]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
mdadm/Build:check the level parameter when build new array
authorZhilong Liu <zlliu@suse.com>
Tue, 28 Mar 2017 13:52:27 +0000 (21:52 +0800)
committerJes Sorensen <Jes.Sorensen@gmail.com>
Tue, 28 Mar 2017 18:26:47 +0000 (14:26 -0400)
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>
Build.c

diff --git a/Build.c b/Build.c
index 74a440e78965d76c9d1c3d97236593a00b97bcf2..a5fcc06b95bbff3cf79ba6b371a613a37066ae01 100644 (file)
--- a/Build.c
+++ b/Build.c
@@ -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++;