X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=mdadm.c;h=f6f5b53af5279134908e0e962c75cf7f6cf1bae2;hb=a34c8836f02c18814f146d3d8b7e415b152ee1ca;hp=14005b3e25a70860f4bbbb695feb2a5282467e36;hpb=9ccfd3be3089fef5d795bc3e6d39ac2c1c880009;p=thirdparty%2Fmdadm.git diff --git a/mdadm.c b/mdadm.c index 14005b3e..f6f5b53a 100644 --- a/mdadm.c +++ b/mdadm.c @@ -1,7 +1,7 @@ /* * mdadm - manage Linux "md" devices aka RAID arrays. * - * Copyright (C) 2001-2012 Neil Brown + * Copyright (C) 2001-2013 Neil Brown * * * This program is free software; you can redistribute it and/or modify @@ -116,13 +116,6 @@ int main(int argc, char *argv[]) ident.container = NULL; ident.member = NULL; - /* - * set first char of argv[0] to @. This is used by - * systemd to signal that the task was launched from - * initrd/initramfs and should be preserved during shutdown - */ - argv[0][0] = '@'; - while ((option_index = -1) , (opt=getopt_long(argc, argv, shortopt, long_options, @@ -194,6 +187,7 @@ int main(int argc, char *argv[]) break; case 'a': case Add: + case AddSpare: case 'r': case Remove: case Replace: @@ -922,6 +916,9 @@ int main(int argc, char *argv[]) case O(MANAGE,Add): /* add a drive */ devmode = 'a'; continue; + case O(MANAGE,AddSpare): /* add drive - never re-add */ + devmode = 'S'; + continue; case O(MANAGE,ReAdd): devmode = 'A'; continue; @@ -1300,7 +1297,7 @@ int main(int argc, char *argv[]) if (!rv && c.readonly < 0) rv = Manage_ro(devlist->devname, mdfd, c.readonly); if (!rv && c.runstop > 0) - rv = Manage_run(devlist->devname, mdfd, c.verbose); + rv = Manage_run(devlist->devname, mdfd, &c); if (!rv && c.runstop < 0) rv = Manage_stop(devlist->devname, mdfd, c.verbose, 0); break; @@ -1490,7 +1487,7 @@ int main(int argc, char *argv[]) break; } } - if (devs_found > 1 && s.raiddisks == 0) { + if (devs_found > 1 && s.raiddisks == 0 && s.level == UnSet) { /* must be '-a'. */ if (s.size > 0 || s.chunk || s.layout_str != NULL || s.bitmap_file) { pr_err("--add cannot be used with " @@ -1534,6 +1531,11 @@ int main(int argc, char *argv[]) RebuildMap(); } if (c.scan) { + rv = 1; + if (devlist) { + pr_err("In --incremental mode, a device cannot be given with --scan.\n"); + break; + } if (c.runstop <= 0) { pr_err("--incremental --scan meaningless without --run.\n"); break; @@ -1542,7 +1544,7 @@ int main(int argc, char *argv[]) pr_err("--incremental --scan --fail not supported.\n"); break; } - rv = IncrementalScan(c.verbose); + rv = IncrementalScan(&c, NULL); } if (!devlist) { if (!rebuild_map && !c.scan) { @@ -1551,16 +1553,16 @@ int main(int argc, char *argv[]) } break; } - if (devlist->next) { - pr_err("--incremental can only handle one device.\n"); - rv = 1; - break; - } - if (devmode == 'f') + if (devmode == 'f') { + if (devlist->next) { + pr_err("'--incremental --fail' can only handle one device.\n"); + rv = 1; + break; + } rv = IncrementalRemove(devlist->devname, remove_path, c.verbose); - else - rv = Incremental(devlist->devname, &c, ss); + } else + rv = Incremental(devlist, &c, ss); break; case AUTODETECT: autodetect(); @@ -1811,7 +1813,8 @@ static int misc_list(struct mddev_dev *devlist, if (mdfd>=0) { switch(dv->disposition) { case 'R': - rv |= Manage_run(dv->devname, mdfd, c->verbose); break; + c->runstop = 1; + rv |= Manage_run(dv->devname, mdfd, c); break; case 'S': rv |= Manage_stop(dv->devname, mdfd, c->verbose, 0); break; case 'o':