]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Assemble.c
Detail: export MD_UUID from mapfile
[thirdparty/mdadm.git] / Assemble.c
index 13953bda495b5a8a0a9a530608017322f8a7e296..7da090506a224d0f6efdf4288ee8537c2ac10cb1 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * mdadm - manage Linux "md" devices aka RAID arrays.
  *
- * Copyright (C) 2001-2006 Neil Brown <neilb@suse.de>
+ * Copyright (C) 2001-2009 Neil Brown <neilb@suse.de>
  *
  *
  *    This program is free software; you can redistribute it and/or modify
  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  *    Author: Neil Brown
- *    Email: <neilb@cse.unsw.edu.au>
- *    Paper: Neil Brown
- *           School of Computer Science and Engineering
- *           The University of New South Wales
- *           Sydney, 2052
- *           Australia
+ *    Email: <neilb@suse.de>
  */
 
 #include       "mdadm.h"
@@ -79,7 +74,7 @@ int Assemble(struct supertype *st, char *mddev,
             mddev_ident_t ident,
             mddev_dev_t devlist, char *backup_file,
             int readonly, int runstop,
-            char *update, char *homehost,
+            char *update, char *homehost, int require_homehost,
             int verbose, int force)
 {
        /*
@@ -188,6 +183,8 @@ int Assemble(struct supertype *st, char *mddev,
        if (!devlist &&
            ident->uuid_set == 0 &&
            ident->super_minor < 0 &&
+           ident->name[0] == 0 &&
+           (ident->container == NULL || ident->member == NULL) &&
            ident->devices == NULL) {
                fprintf(stderr, Name ": No identity information available for %s - cannot assemble.\n",
                        mddev ? mddev : "further assembly");
@@ -323,6 +320,8 @@ int Assemble(struct supertype *st, char *mddev,
                                content = tmpdev->content;
                        else
                                content = tst->ss->container_content(tst);
+                       if (!content)
+                               goto loop; /* empty container */
 
                        tmpdev->content = content->next;
                        if (tmpdev->content == NULL)
@@ -480,17 +479,14 @@ int Assemble(struct supertype *st, char *mddev,
        if (!st || !st->sb || !content)
                return 2;
 
-       /* Now need to open array the device.  Use create_mddev */
+       /* Now need to open the array device.  Use create_mddev */
        if (content == &info)
                st->ss->getinfo_super(st, content);
 
        trustworthy = FOREIGN;
+       name = content->name;
        switch (st->ss->match_home(st, homehost)
                ?: st->ss->match_home(st, "any")) {
-       case 0:
-               trustworthy = FOREIGN;
-               name = content->name;
-               break;
        case 1:
                trustworthy = LOCAL;
                name = strchr(content->name, ':');
@@ -499,22 +495,30 @@ int Assemble(struct supertype *st, char *mddev,
                else
                        name = content->name;
                break;
-       case -1:
-               trustworthy = FOREIGN;
-               break;
        }
-       if (!auto_assem && trustworthy == FOREIGN)
+       if (!auto_assem)
                /* If the array is listed in mdadm.conf or on
                 * command line, then we trust the name
                 * even if the array doesn't look local
                 */
                trustworthy = LOCAL;
 
-       if (content->name[0] == 0 &&
+       if (name[0] == 0 &&
            content->array.level == LEVEL_CONTAINER) {
                name = content->text_version;
                trustworthy = METADATA;
        }
+
+       if (name[0] && trustworthy != LOCAL &&
+           ! require_homehost &&
+           conf_name_is_free(name))
+               trustworthy = LOCAL;
+
+       if (trustworthy == LOCAL &&
+           strchr(name, ':'))
+               /* Ignore 'host:' prefix of name */
+               name = strchr(name, ':')+1;
+
        mdfd = create_mddev(mddev, name, ident->autof, trustworthy,
                            chosen_name);
        if (mdfd < 0) {
@@ -561,6 +565,7 @@ int Assemble(struct supertype *st, char *mddev,
 #endif
        /* Ok, no bad inconsistancy, we can try updating etc */
        bitmap_done = 0;
+       content->update_private = NULL;
        for (tmpdev = devlist; tmpdev; tmpdev=tmpdev->next) if (tmpdev->used == 1) {
                char *devname = tmpdev->devname;
                struct stat stb;
@@ -713,6 +718,8 @@ int Assemble(struct supertype *st, char *mddev,
                }
                devcnt++;
        }
+       free(content->update_private);
+       content->update_private = NULL;
 
        if (devcnt == 0) {
                fprintf(stderr, Name ": no devices found for %s\n",