diff options
author | NeilBrown <neilb@suse.de> | 2009-07-14 12:13:29 +1000 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2009-07-14 12:13:29 +1000 |
commit | 19678e536d5b7aba8b721a3065f2550b79ddd208 (patch) | |
tree | 7537fe1a28214e5fe490b8f8524fb1430c4d26c3 /mdadm.c | |
parent | d823a6c87225d0c7f96443013798ed4dacf51ff6 (diff) | |
download | mdadm-19678e536d5b7aba8b721a3065f2550b79ddd208.tar.gz |
Grow: pass layout as a string rather than a number.
This allows the layout to be parsed after the current level of the
array is know, so that the level doesn't need to be given (otherwise
pointlessly) on the command line.
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'mdadm.c')
-rw-r--r-- | mdadm.c | 25 |
1 files changed, 18 insertions, 7 deletions
@@ -49,6 +49,7 @@ int main(int argc, char *argv[]) long long array_size = -1; int level = UnSet; int layout = UnSet; + char *layout_str = NULL; int raiddisks = 0; int max_disks = MD_SB_DISKS; /* just a default */ int sparedisks = 0; @@ -442,9 +443,18 @@ int main(int argc, char *argv[]) ident.level = level; continue; + case O(GROW, 'p'): /* new layout */ + if (layout_str) { + fprintf(stderr,Name ": layout may only be sent once. " + "Second value was %s\n", optarg); + exit(2); + } + layout_str = optarg; + /* 'Grow' will parse the value */ + continue; + case O(CREATE,'p'): /* raid5 layout */ case O(BUILD,'p'): /* faulty layout */ - case O(GROW, 'p'): /* faulty reconfig */ if (layout != UnSet) { fprintf(stderr,Name ": layout may only be sent once. " "Second value was %s\n", optarg); @@ -483,9 +493,10 @@ int main(int argc, char *argv[]) exit(2); } break; - case -5: /* Faulty - * modeNNN - */ + case LEVEL_FAULTY: + /* Faulty + * modeNNN + */ layout = parse_layout_faulty(optarg); if (layout == -1) { fprintf(stderr, Name ": layout %s not understood for faulty.\n", @@ -1409,13 +1420,13 @@ int main(int argc, char *argv[]) if (rv) break; } - } else if ((size >= 0) + (raiddisks != 0) + (layout != UnSet) + (bitmap_file != NULL)> 1) { + } else if ((size >= 0) + (raiddisks != 0) + (layout_str != NULL) + (bitmap_file != NULL)> 1) { fprintf(stderr, Name ": can change at most one of size, raiddisks, bitmap, and layout\n"); rv = 1; break; - } else if (size >= 0 || raiddisks || layout != UnSet) + } else if (size >= 0 || raiddisks || layout_str != NULL) rv = Grow_reshape(devlist->devname, mdfd, quiet, backup_file, - size, level, layout, chunk, raiddisks); + size, level, layout_str, chunk, raiddisks); else if (bitmap_file) { if (delay == 0) delay = DEFAULT_BITMAP_DELAY; rv = Grow_addbitmap(devlist->devname, mdfd, bitmap_file, |