]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - super-ddf.c
Kill subarray v2
[thirdparty/mdadm.git] / super-ddf.c
index b1cb268960616209d3cd8c7c87f8d705c93e2e94..736e07f374a44e09ae266681676bd3add839a522 100644 (file)
@@ -783,6 +783,10 @@ static int load_super_ddf(struct supertype *st, int fd,
        if (get_dev_size(fd, devname, &dsize) == 0)
                return 1;
 
+       if (test_partition(fd))
+               /* DDF is not allowed on partitions */
+               return 1;
+
        /* 32M is a lower bound */
        if (dsize <= 32*1024*1024) {
                if (devname)
@@ -841,10 +845,18 @@ static int load_super_ddf(struct supertype *st, int fd,
        }
 
        if (st->subarray[0]) {
+               unsigned long val;
                struct vcl *v;
+               char *ep;
+
+               val = strtoul(st->subarray, &ep, 10);
+               if (*ep != '\0') {
+                       free(super);
+                       return 1;
+               }
 
                for (v = super->conflist; v; v = v->next)
-                       if (v->vcnum == atoi(st->subarray))
+                       if (v->vcnum == val)
                                super->currentconf = v;
                if (!super->currentconf) {
                        free(super);
@@ -2413,8 +2425,12 @@ static int write_init_super_ddf(struct supertype *st)
 
                /* FIXME I need to close the fds! */
                return 0;
-       } else 
+       } else {        
+               struct dl *d;
+               for (d = ddf->dlist; d; d=d->next)
+                       while (Kill(d->devname, NULL, 0, 1, 1) == 0);
                return __write_init_super_ddf(st, 1);
+       }
 }
 
 #endif
@@ -2862,14 +2878,25 @@ static int load_super_ddf_all(struct supertype *st, int fd,
                        return 1;
        }
        if (st->subarray[0]) {
+               unsigned long val;
                struct vcl *v;
+               char *ep;
+
+               val = strtoul(st->subarray, &ep, 10);
+               if (*ep != '\0') {
+                       free(super);
+                       return 1;
+               }
 
                for (v = super->conflist; v; v = v->next)
-                       if (v->vcnum == atoi(st->subarray))
+                       if (v->vcnum == val)
                                super->currentconf = v;
-               if (!super->currentconf)
+               if (!super->currentconf) {
+                       free(super);
                        return 1;
+               }
        }
+
        *sbp = super;
        if (st->ss == NULL) {
                st->ss = &super_ddf;