]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - mdadm.c
Fix parsing of "-a" in various contexts.
[thirdparty/mdadm.git] / mdadm.c
diff --git a/mdadm.c b/mdadm.c
index e5ed93de4b1c6c88b98395387ba07c7a9e0aa9fe..e96ce68aa41e2980a1b0a161cd9ab04063c76b77 100644 (file)
--- a/mdadm.c
+++ b/mdadm.c
@@ -74,6 +74,7 @@ int main(int argc, char *argv[])
        int brief = 0;
        int force = 0;
        int test = 0;
+       int export = 0;
        int assume_clean = 0;
        char *symlinks = NULL;
        /* autof indicates whether and how to create device node.
@@ -159,6 +160,9 @@ int main(int argc, char *argv[])
                        }
                        continue;
 
+               case 'Y': export++;
+                       continue;
+
                case HomeHost:
                        homehost = optarg;
                        continue;
@@ -176,7 +180,7 @@ int main(int argc, char *argv[])
                switch(opt) {
                case '@': /* just incase they say --manage */
                        newmode = MANAGE;
-                       shortopt = short_bitmap_auto_options;
+                       shortopt = short_bitmap_options;
                        break;
                case 'a':
                case 'r':
@@ -184,7 +188,7 @@ int main(int argc, char *argv[])
                case ReAdd: /* re-add */
                        if (!mode) {
                                newmode = MANAGE;
-                               shortopt = short_bitmap_auto_options;
+                               shortopt = short_bitmap_options;
                        }
                        break;
 
@@ -192,8 +196,12 @@ int main(int argc, char *argv[])
                case 'B': newmode = BUILD; shortopt = short_bitmap_auto_options; break;
                case 'C': newmode = CREATE; shortopt = short_bitmap_auto_options; break;
                case 'F': newmode = MONITOR;break;
-               case 'G': newmode = GROW; shortopt = short_bitmap_auto_options; break;
+               case 'G': newmode = GROW;
+                       shortopt = short_bitmap_options;
+                       break;
                case 'I': newmode = INCREMENTAL; break;
+               case AutoDetect:
+                       newmode = AUTODETECT; break;
 
                case '#':
                case 'D':
@@ -273,6 +281,7 @@ int main(int argc, char *argv[])
                case 'F':
                case 'G':
                case 'I':
+               case AutoDetect:
                        continue;
                }
                if (opt == 1) {
@@ -1134,6 +1143,11 @@ int main(int argc, char *argv[])
                        rv = 1;
                        break;
                }
+               if (raiddisks == 0) {
+                       fprintf(stderr, Name ": no raid-disks specified.\n");
+                       rv = 1;
+                       break;
+               }
 
                if (bitmap_file) {
                        if (strcmp(bitmap_file, "internal")==0) {
@@ -1153,6 +1167,11 @@ int main(int argc, char *argv[])
                        rv = 1;
                        break;
                }
+               if (raiddisks == 0) {
+                       fprintf(stderr, Name ": no raid-disks specified.\n");
+                       rv = 1;
+                       break;
+               }
 
                rv = Create(ss, devlist->devname, mdfd, chunk, level, layout, size<0 ? 0 : size,
                            raiddisks, sparedisks, ident.name, homehost,
@@ -1189,7 +1208,8 @@ int main(int argc, char *argv[])
                                                                e->dev);
                                                        continue;
                                                }
-                                               rv |= Detail(name, verbose>1?0:verbose+1, test, homehost);
+                                               rv |= Detail(name, verbose>1?0:verbose+1,
+                                                            export, test, homehost);
                                                put_md_name(name);
                                        }
                                } else  if (devmode == 'S' && scan) {
@@ -1234,7 +1254,10 @@ int main(int argc, char *argv[])
                        for (dv=devlist ; dv; dv=dv->next) {
                                switch(dv->disposition) {
                                case 'D':
-                                       rv |= Detail(dv->devname, brief?1+verbose:0, test, homehost); continue;
+                                       rv |= Detail(dv->devname,
+                                                    brief?1+verbose:0,
+                                                    export, test, homehost);
+                                       continue;
                                case 'K': /* Zero superblock */
                                        rv |= Kill(dv->devname, force, quiet); continue;
                                case 'Q':
@@ -1336,6 +1359,10 @@ int main(int argc, char *argv[])
                }
                rv = Incremental(devlist->devname, verbose-quiet, runstop,
                                 ss, homehost, autof);
+               break;
+       case AUTODETECT:
+               autodetect();
+               break;
        }
        exit(rv);
 }