]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - mdadm.c
Fix bug on new --detail code
[thirdparty/mdadm.git] / mdadm.c
diff --git a/mdadm.c b/mdadm.c
index de1f95a93f1c403b77b0902ba43b995d8feafb8e..bd29882c1b5fa2770fc49ef429ecbdf742c467c0 100644 (file)
--- a/mdadm.c
+++ b/mdadm.c
@@ -70,6 +70,7 @@ int main(int argc, char *argv[])
        mddev_dev_t dv;
        int devs_found = 0;
        int verbose = 0;
+       int quiet = 0;
        int brief = 0;
        int force = 0;
        int test = 0;
@@ -91,6 +92,7 @@ int main(int argc, char *argv[])
        int oneshot = 0;
        struct supertype *ss = NULL;
        int writemostly = 0;
+       int re_add = 0;
 
        int copies;
 
@@ -114,7 +116,7 @@ int main(int argc, char *argv[])
                                short_options, long_options,
                                &option_index)) != -1) {
                int newmode = mode;
-               /* firstly, so mode-independant options */
+               /* firstly, some mode-independant options */
                switch(opt) {
                case 'h':
                        help_text = Help;
@@ -141,6 +143,9 @@ int main(int argc, char *argv[])
                case 'v': verbose++;
                        continue;
 
+               case 'q': quiet++;
+                       continue;
+
                case 'b':
                        if (mode == ASSEMBLE || mode == BUILD || mode == CREATE || mode == GROW)
                                break; /* b means bitmap */
@@ -163,6 +168,7 @@ int main(int argc, char *argv[])
                case 'a':
                case 'r':
                case 'f':
+               case 6: /* re-add */
                        if (!mode) newmode = MANAGE; 
                        break;
 
@@ -218,6 +224,7 @@ int main(int argc, char *argv[])
                                        dv->devname = optarg;
                                        dv->disposition = devmode;
                                        dv->writemostly = writemostly;
+                                       dv->re_add = re_add;
                                        dv->next = NULL;
                                        *devlistend = dv;
                                        devlistend = &dv->next;
@@ -267,6 +274,7 @@ int main(int argc, char *argv[])
                        dv->devname = optarg;
                        dv->disposition = devmode;
                        dv->writemostly = writemostly;
+                       dv->re_add = re_add;
                        dv->next = NULL;
                        *devlistend = dv;
                        devlistend = &dv->next;
@@ -663,6 +671,11 @@ int main(int argc, char *argv[])
                case O(GROW,'a'):
                case O(MANAGE,'a'): /* add a drive */
                        devmode = 'a';
+                       re_add = 0;
+                       continue;
+               case O(MANAGE,6):
+                       devmode = 'a';
+                       re_add = 1;
                        continue;
                case O(MANAGE,'r'): /* remove a drive */
                        devmode = 'r';
@@ -860,7 +873,7 @@ int main(int argc, char *argv[])
                        rv = Manage_ro(devlist->devname, mdfd, readonly);
                if (!rv && devs_found>1)
                        rv = Manage_subdevs(devlist->devname, mdfd,
-                                           devlist->next);
+                                           devlist->next, verbose-quiet);
                if (!rv && readonly < 0)
                        rv = Manage_ro(devlist->devname, mdfd, readonly);
                if (!rv && runstop)
@@ -883,14 +896,14 @@ int main(int argc, char *argv[])
                                else {
                                        rv |= Assemble(ss, devlist->devname, mdfd, array_ident, configfile,
                                                       NULL,
-                                                      readonly, runstop, update, verbose, force);
+                                                      readonly, runstop, update, verbose-quiet, force);
                                        close(mdfd);
                                }
                        }
                } else if (!scan)
                        rv = Assemble(ss, devlist->devname, mdfd, &ident, configfile,
                                      devlist->next,
-                                     readonly, runstop, update, verbose, force);
+                                     readonly, runstop, update, verbose-quiet, force);
                else if (devs_found>0) {
                        if (update && devs_found > 1) {
                                fprintf(stderr, Name ": can only update a single array at a time\n");
@@ -912,7 +925,7 @@ int main(int argc, char *argv[])
                                }
                                rv |= Assemble(ss, dv->devname, mdfd, array_ident, configfile,
                                               NULL,
-                                              readonly, runstop, update, verbose, force);
+                                              readonly, runstop, update, verbose-quiet, force);
                                close(mdfd);
                        }
                } else {
@@ -936,7 +949,7 @@ int main(int argc, char *argv[])
                                                rv |= Assemble(ss, array_list->devname, mdfd,
                                                               array_list, configfile,
                                                               NULL,
-                                                              readonly, runstop, NULL, verbose, force);
+                                                              readonly, runstop, NULL, verbose-quiet, force);
                                        close(mdfd);
                                }
                }
@@ -956,20 +969,10 @@ int main(int argc, char *argv[])
                                rv |= 1;
                                break;
                        }
-                       bitmap_fd = open(bitmap_file, O_RDWR,0);
-                       if (bitmap_fd < 0 && errno != ENOENT) {
-                               perror(Name ": cannot create bitmap file");
-                               rv |= 1;
-                               break;
-                       }
-                       if (bitmap_fd < 0) {
-                               bitmap_fd = CreateBitmap(bitmap_file, force, NULL,
-                                                        bitmap_chunk, delay, write_behind, size);
-                       }
                }
                rv = Build(devlist->devname, mdfd, chunk, level, layout,
                           raiddisks, devlist->next, assume_clean,
-                          bitmap_file, bitmap_chunk, write_behind, delay);
+                          bitmap_file, bitmap_chunk, write_behind, delay, verbose-quiet);
                break;
        case CREATE:
                if (delay == 0) delay = DEFAULT_BITMAP_DELAY;
@@ -989,7 +992,7 @@ int main(int argc, char *argv[])
 
                rv = Create(ss, devlist->devname, mdfd, chunk, level, layout, size<0 ? 0 : size,
                            raiddisks, sparedisks, ident.name,
-                           devs_found-1, devlist->next, runstop, verbose, force,
+                           devs_found-1, devlist->next, runstop, verbose-quiet, force,
                            bitmap_file, bitmap_chunk, write_behind, delay);
                break;
        case MISC: