Merge branch 'master' in devel-3.0
[thirdparty/mdadm.git] / mdassemble.c
index b0d87b8..2b955c5 100644 (file)
@@ -55,7 +55,7 @@ mapping_t pers[] = {
 
 #ifndef MDASSEMBLE_AUTO
 /* from mdopen.c */
-int open_mddev(char *dev, int autof/*unused */)
+int open_mddev(char *dev, int report_errors/*unused*/)
 {
        int mdfd = open(dev, O_RDWR);
        if (mdfd < 0)
@@ -69,7 +69,21 @@ int open_mddev(char *dev, int autof/*unused */)
        }
        return mdfd;
 }
+int create_mddev(char *dev, char *name, int autof/*unused*/, int trustworthy,
+                char *chosen)
+{
+       return open_mddev(dev, 0);
+}
 #endif
+int map_update(struct map_ent **mpp, int devnum, char *metadata,
+              int *uuid, char *path)
+{
+       return 0;
+}
+struct map_ent *map_by_name(struct map_ent **mpp, char *name)
+{
+       return NULL;
+}
 
 int rv;
 int mdfd = -1;
@@ -86,19 +100,16 @@ int main(int argc, char *argv[]) {
        } else
                for (; array_list; array_list = array_list->next) {
                        mdu_array_info_t array;
-                       mdfd = open_mddev(array_list->devname, array_list->autof);
-                       if (mdfd < 0) {
-                               rv |= 1;
-                               continue;
-                       }
-                       if (ioctl(mdfd, GET_ARRAY_INFO, &array) < 0) {
-                               rv |= Assemble(array_list->st, array_list->devname, mdfd,
-                                          array_list, NULL, NULL,
-                                          readonly, runstop, NULL, NULL, verbose, force);
-                       } else {
+                       mdfd = open_mddev(array_list->devname, 0);
+                       if (mdfd >= 0 && ioctl(mdfd, GET_ARRAY_INFO, &array) == 0) {
                                rv |= Manage_ro(array_list->devname, mdfd, -1); /* make it readwrite */
+                               continue;
                        }
-                       close(mdfd);
+                       if (mdfd >= 0)
+                               close(mdfd);
+                       rv |= Assemble(array_list->st, array_list->devname,
+                                      array_list, NULL, NULL,
+                                      readonly, runstop, NULL, NULL, verbose, force);
                }
        return rv;
 }