]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - util.c
Pass subarray arg explicitly to ->update_subarray.
[thirdparty/mdadm.git] / util.c
diff --git a/util.c b/util.c
index c9976218962ab0ddeda0d4ff7ad40ab8c45b8b74..83a972e79c16032f296d93409b64dee712bc7d29 100644 (file)
--- a/util.c
+++ b/util.c
@@ -500,7 +500,7 @@ int check_raid(int fd, char *name)
        /* Looks like a raid array .. */
        fprintf(stderr, Name ": %s appears to be part of a raid array:\n",
                name);
-       st->ss->getinfo_super(st, &info);
+       st->ss->getinfo_super(st, &info, NULL);
        st->ss->free_super(st);
        crtime = info.array.ctime;
        level = map_num(pers, info.array.level);
@@ -1032,7 +1032,7 @@ struct superswitch *superlist[] =
 
 #if !defined(MDASSEMBLE) || defined(MDASSEMBLE) && defined(MDASSEMBLE_AUTO)
 
-struct supertype *super_by_fd(int fd)
+struct supertype *super_by_fd(int fd, char **subarrayp)
 {
        mdu_array_info_t array;
        int vers;
@@ -1086,13 +1086,10 @@ struct supertype *super_by_fd(int fd)
                sysfs_free(sra);
        if (st) {
                st->sb = NULL;
-               if (subarray) {
-                       strncpy(st->subarray, subarray, 32);
-                       st->subarray[31] = 0;
-                       free(subarray);
-               } else
-                       st->subarray[0] = 0;
-       }
+               st->subarray[0] = 0;
+               *subarrayp = subarray;
+       } else
+               free(subarray);
        return st;
 }
 #endif /* !defined(MDASSEMBLE) || defined(MDASSEMBLE) && defined(MDASSEMBLE_AUTO) */
@@ -1140,7 +1137,7 @@ struct supertype *guess_super_type(int fd, enum guess_types guess_type)
                rv = ss->load_super(st, fd, NULL);
                if (rv == 0) {
                        struct mdinfo info;
-                       st->ss->getinfo_super(st, &info);
+                       st->ss->getinfo_super(st, &info, NULL);
                        if (bestsuper == -1 ||
                            besttime < info.array.ctime) {
                                bestsuper = i;
@@ -1441,14 +1438,15 @@ int is_container_active(char *container)
 
 /* open_subarray - opens a subarray in a container
  * @dev: container device name
- * @st: supertype with only ->subarray set
+ * @st: empty supertype
  * @quiet: block reporting errors flag
  *
  * On success returns an fd to a container and fills in *st
  */
-int open_subarray(char *dev, struct supertype *st, int quiet)
+int open_subarray(char *dev, char *subarray, struct supertype *st, int quiet)
 {
        struct mdinfo *mdi;
+       struct mdinfo *info;
        int fd, err = 1;
 
        fd = open(dev, O_RDWR|O_EXCL);
@@ -1500,8 +1498,8 @@ int open_subarray(char *dev, struct supertype *st, int quiet)
 
        if (st->ss->load_super(st, fd, NULL)) {
                if (!quiet)
-                       fprintf(stderr, Name ": Failed to find subarray-%s in %s\n",
-                               st->subarray, dev);
+                       fprintf(stderr, Name ": Failed to load metadata for %s\n",
+                               dev);
                goto free_name;
        }
 
@@ -1511,6 +1509,15 @@ int open_subarray(char *dev, struct supertype *st, int quiet)
                goto free_super;
        }
 
+       info = st->ss->container_content(st, subarray);
+       if (!info) {
+               if (!quiet)
+                       fprintf(stderr, Name ": Failed to find subarray-%s in %s\n",
+                               subarray, dev);
+               goto free_super;
+       }
+       free(info);
+
        err = 0;
 
  free_super: