]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - mdadm.c
Create: allow chunksize to be non-power-of-2.
[thirdparty/mdadm.git] / mdadm.c
diff --git a/mdadm.c b/mdadm.c
index c44c43228067c536eeccd18d2480310bc0dac444..d55e9cfa3081b0a91d7f0d93f9e5de3679e58232 100644 (file)
--- a/mdadm.c
+++ b/mdadm.c
@@ -103,7 +103,6 @@ int main(int argc, char *argv[])
        char *shortopt = short_options;
        int dosyslog = 0;
        int rebuild_map = 0;
-       int auto_update_home = 0;
        char *subarray = NULL;
        char *remove_path = NULL;
        char *udev_filename = NULL;
@@ -254,6 +253,12 @@ int main(int argc, char *argv[])
                        exit(2);
                } else if (!mode && newmode) {
                        mode = newmode;
+                       if (mode == MISC && devs_found) {
+                               fprintf(stderr, Name ": No action given for %s in --misc mode\n",
+                                       devlist->devname);
+                               fprintf(stderr,"       Action options must come before device names\n");
+                               exit(2);
+                       }
                } else {
                        /* special case of -c --help */
                        if ((opt == 'c' || opt == ConfigFile) &&
@@ -356,20 +361,15 @@ int main(int argc, char *argv[])
                                exit(2);
                        }
                        chunk = parse_size(optarg);
-                       if (chunk < 8 || ((chunk-1)&chunk)) {
+                       if (chunk < 8 || (chunk&1)) {
                                fprintf(stderr, Name ": invalid chunk/rounding value: %s\n",
                                        optarg);
                                exit(2);
                        }
-                       /* Covert sectors to K */
+                       /* Convert sectors to K */
                        chunk /= 2;
                        continue;
 
-#if 0
-               case O(ASSEMBLE,AutoHomeHost):
-                       auto_update_home = 1;
-                       continue;
-#endif
                case O(INCREMENTAL, 'e'):
                case O(CREATE,'e'):
                case O(ASSEMBLE,'e'):
@@ -1173,12 +1173,16 @@ int main(int argc, char *argv[])
 
        if (homehost == NULL)
                homehost = conf_get_homehost(&require_homehost);
-       if (homehost == NULL || strcmp(homehost, "<system>")==0) {
+       if (homehost == NULL || strcasecmp(homehost, "<system>")==0) {
                if (gethostname(sys_hostname, sizeof(sys_hostname)) == 0) {
                        sys_hostname[sizeof(sys_hostname)-1] = 0;
                        homehost = sys_hostname;
                }
        }
+       if (homehost && (!homehost[0] || strcasecmp(homehost, "<none>") == 0)) {
+               homehost = NULL;
+               require_homehost = 0;
+       }
 
        if ((mode != MISC || devmode != 'E') &&
            geteuid() != 0) {
@@ -1325,38 +1329,9 @@ int main(int argc, char *argv[])
                                                        cnt++;
                                                        acnt++;
                                                }
-                                               if (rv2 == 1)
-                                                       /* found something so even though assembly failed  we
-                                                        * want to avoid auto-updates
-                                                        */
-                                                       auto_update_home = 0;
                                        } while (rv2!=2);
                                        /* Incase there are stacked devices, we need to go around again */
                                } while (acnt);
-#if 0
-                               if (cnt == 0 && auto_update_home && homehost) {
-                                       /* Nothing found, maybe we need to bootstrap homehost info */
-                                       do {
-                                               acnt = 0;
-                                               do {
-                                                       rv2 = Assemble(
-                                                               ss, NULL,
-                                                               &ident,
-                                                               NULL, NULL, 0,
-                                                               readonly, runstop,
-                                                               "homehost",
-                                                               homehost,
-                                                               require_homehost,
-                                                               verbose-quiet, force);
-                                                       if (rv2==0) {
-                                                               cnt++;
-                                                               acnt++;
-                                                       }
-                                               } while (rv2!=2);
-                                               /* Incase there are stacked devices, we need to go around again */
-                                       } while (acnt);
-                               }
-#endif
                                if (cnt == 0 && rv == 0) {
                                        fprintf(stderr, Name ": No arrays found in config file or automatically\n");
                                        rv = 1;
@@ -1646,7 +1621,7 @@ int main(int argc, char *argv[])
                        }
                } else if (bitmap_file) {
                        if (size >= 0 || raiddisks || chunk ||
-                           layout_str != NULL || devs_found) {
+                           layout_str != NULL || devs_found > 1) {
                                fprintf(stderr, Name ": --bitmap changes cannot be "
                                        "used with other geometry changes "
                                        "in --grow mode\n");