]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Assemble.c
Various compile fixes.
[thirdparty/mdadm.git] / Assemble.c
index ea54fc099d8f9cc060efb9dd1bdb3a298f97deba..317be8b7314595adef30df09f3482418818b2aaa 100644 (file)
@@ -330,11 +330,13 @@ int Assemble(struct supertype *st, char *mddev,
                                        fprintf(stderr, Name ": %s is a container, but we are looking for components\n",
                                                devname);
                                tmpdev->used = 2;
+#if !defined(MDASSEMBLE) || defined(MDASSEMBLE) && defined(MDASSEMBLE_AUTO)
                        } if (!tst && (tst = super_by_fd(dfd, NULL)) == NULL) {
                                if (report_missmatch)
                                        fprintf(stderr, Name ": not a recognisable container: %s\n",
                                                devname);
                                tmpdev->used = 2;
+#endif
                        } else if (!tst->ss->load_container
                                   || tst->ss->load_container(tst, dfd, NULL)) {
                                if (report_missmatch)
@@ -595,10 +597,15 @@ int Assemble(struct supertype *st, char *mddev,
                                tmpdev->devname, strerror(errno));
                        tmpdev->used = 2;
                } else {
-                       struct dev_policy *pol = NULL;
-                       pol = devnum_policy(stb.st_rdev);
-                       if (domain_test(domains, pol, NULL))
-                               /* take this spare if domains match */
+                       struct dev_policy *pol = devnum_policy(stb.st_rdev);
+                       int dt = domain_test(domains, pol, NULL);
+                       if (inargv && dt != 0)
+                               /* take this spare as domains match
+                                * if there are any */
+                               tmpdev->used = 1;
+                       else if (!inargv && dt == 1)
+                               /* device wasn't explicitly listed, so need
+                                * explicit domain match - which we have */
                                tmpdev->used = 1;
                        else
                                /* if domains don't match mark as unused */
@@ -1304,6 +1311,7 @@ int Assemble(struct supertype *st, char *mddev,
                                                content->array.raid_disks);
                                fprintf(stderr, "\n");
                        }
+                       st->ss->free_super(st);
                        sysfs_uevent(content, "change");
                        wait_for(chosen_name, mdfd);
                        close(mdfd);