]> git.ipfire.org Git - thirdparty/mdadm.git/blame - mdadm.c
Limit size of bitmap to 2million chunks.
[thirdparty/mdadm.git] / mdadm.c
CommitLineData
64c4757e 1/*
9a9dab36 2 * mdadm - manage Linux "md" devices aka RAID arrays.
64c4757e 3 *
cd29a5c8 4 * Copyright (C) 2001-2002 Neil Brown <neilb@cse.unsw.edu.au>
64c4757e
NB
5 *
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 * Author: Neil Brown
22 * Email: <neilb@cse.unsw.edu.au>
23 * Paper: Neil Brown
24 * School of Computer Science and Engineering
25 * The University of New South Wales
26 * Sydney, 2052
27 * Australia
c82f047c 28 *
dfd4d8ee 29 * Additions for bitmap and write-behind RAID options, Copyright (C) 2003-2004,
c82f047c 30 * Paul Clements, SteelEye Technology, Inc.
64c4757e
NB
31 */
32
9a9dab36 33#include "mdadm.h"
64c4757e 34#include "md_p.h"
dd0781e5 35#include <ctype.h>
64c4757e 36
dd0781e5 37
52826846
NB
38int main(int argc, char *argv[])
39{
e0d19036 40 int mode = 0;
52826846 41 int opt;
e0d19036 42 int option_index;
52826846
NB
43 char *c;
44 int rv;
f9ce90ba 45 int i;
52826846
NB
46
47 int chunk = 0;
5dd497ee 48 long long size = -1;
98c6faba
NB
49 int level = UnSet;
50 int layout = UnSet;
52826846 51 int raiddisks = 0;
e27d562b 52 int max_disks = MD_SB_DISKS; /* just a default */
52826846
NB
53 int sparedisks = 0;
54 struct mddev_ident_s ident;
55 char *configfile = NULL;
cd29a5c8 56 char *cp;
5787fa49 57 char *update = NULL;
52826846
NB
58 int scan = 0;
59 char devmode = 0;
60 int runstop = 0;
61 int readonly = 0;
dfd4d8ee 62 int write_behind = 0;
c82f047c
NB
63 int bitmap_fd = -1;
64 char *bitmap_file = NULL;
06b0d786 65 char *backup_file = NULL;
c82f047c 66 int bitmap_chunk = UnSet;
bd526cee 67 int SparcAdjust = 0;
cd29a5c8
NB
68 mddev_dev_t devlist = NULL;
69 mddev_dev_t *devlistend = & devlist;
70 mddev_dev_t dv;
52826846
NB
71 int devs_found = 0;
72 int verbose = 0;
dab6685f 73 int quiet = 0;
cd29a5c8 74 int brief = 0;
52826846 75 int force = 0;
feb716e9 76 int test = 0;
dd0781e5 77 int assume_clean = 0;
8d80900b
NB
78 int autof = 0; /* -2 means create device based on name:
79 * if it ends mdN, then non-partitioned array N
80 * if it ends dN, then partitions array N
81 * -1 means create non-partitioned, choose N
82 * 1 or more to create partitioned
83 * If -1 or 1 and name is a 'standard' name, then
84 * insist on a match of type and number.
85 */
52826846
NB
86
87 char *mailaddr = NULL;
88 char *program = NULL;
89 int delay = 0;
d013a55e 90 int daemonise = 0;
b5e64645 91 char *pidfile = NULL;
aa88f531 92 int oneshot = 0;
82d9eba6 93 struct supertype *ss = NULL;
dfd4d8ee 94 int writemostly = 0;
fe80f49b 95 int re_add = 0;
c06487ce 96 char *shortopt = short_options;
773135f5 97 int dosyslog = 0;
52826846 98
e5329c37 99 int copies;
3d4064cc 100 int print_help = 0;
e5329c37 101
52826846
NB
102 int mdfd = -1;
103
dfe47e00
NB
104 srandom(time(0) ^ getpid());
105
52826846 106 ident.uuid_set=0;
98c6faba
NB
107 ident.level = UnSet;
108 ident.raid_disks = UnSet;
109 ident.super_minor= UnSet;
52826846 110 ident.devices=0;
a75f2fbc
NB
111 ident.spare_group = NULL;
112 ident.autof = 0;
a825febc 113 ident.st = NULL;
c82f047c 114 ident.bitmap_fd = -1;
7ef02d01 115 ident.bitmap_file = NULL;
947fd4dd 116 ident.name[0] = 0;
52826846 117
e0d19036
NB
118 while ((option_index = -1) ,
119 (opt=getopt_long(argc, argv,
c06487ce 120 shortopt, long_options,
e0d19036
NB
121 &option_index)) != -1) {
122 int newmode = mode;
dab6685f 123 /* firstly, some mode-independant options */
52826846 124 switch(opt) {
52826846 125 case 'h':
56eedc1a
NB
126 if (option_index > 0 &&
127 strcmp(long_options[option_index].name, "help-options")==0)
3d4064cc 128 print_help = 2;
56eedc1a 129 else
3d4064cc
NB
130 print_help = 1;
131 continue;
52826846
NB
132
133 case 'V':
134 fputs(Version, stderr);
135 exit(0);
136
22892d56 137 case 'v': verbose++;
52826846
NB
138 continue;
139
dab6685f
NB
140 case 'q': quiet++;
141 continue;
142
c82f047c 143 case 'b':
f5e166fe 144 if (mode == ASSEMBLE || mode == BUILD || mode == CREATE || mode == GROW)
c82f047c
NB
145 break; /* b means bitmap */
146 brief = 1;
c06487ce
NB
147 if (optarg) {
148 fprintf(stderr, Name ": -b cannot have any extra immediately after it, sorry.\n");
149 exit(2);
150 }
cd29a5c8
NB
151 continue;
152
e0d19036
NB
153 case ':':
154 case '?':
155 fputs(Usage, stderr);
156 exit(2);
157 }
158 /* second, figure out the mode.
159 * Some options force the mode. Others
160 * set the mode if it isn't already
161 */
162
163 switch(opt) {
164 case '@': /* just incase they say --manage */
c06487ce
NB
165 newmode = MANAGE;
166 shortopt = short_bitmap_auto_options;
167 break;
e0d19036
NB
168 case 'a':
169 case 'r':
170 case 'f':
fe80f49b 171 case 6: /* re-add */
c06487ce
NB
172 if (!mode) {
173 newmode = MANAGE;
174 shortopt = short_bitmap_auto_options;
175 }
0320ea45 176 break;
e0d19036 177
c06487ce
NB
178 case 'A': newmode = ASSEMBLE; shortopt = short_bitmap_auto_options; break;
179 case 'B': newmode = BUILD; shortopt = short_bitmap_auto_options; break;
180 case 'C': newmode = CREATE; shortopt = short_bitmap_auto_options; break;
e0d19036 181 case 'F': newmode = MONITOR;break;
c06487ce 182 case 'G': newmode = GROW; shortopt = short_bitmap_auto_options; break;
e0d19036
NB
183
184 case '#':
185 case 'D':
186 case 'E':
c82f047c 187 case 'X':
e0d19036
NB
188 case 'Q': newmode = MISC; break;
189 case 'R':
190 case 'S':
191 case 'o':
192 case 'w':
193 case 'K': if (!mode) newmode = MISC; break;
194 }
195 if (mode && newmode == mode) {
196 /* everybody happy ! */
197 } else if (mode && newmode != mode) {
198 /* not allowed.. */
199 fprintf(stderr, Name ": ");
200 if (option_index >= 0)
201 fprintf(stderr, "--%s", long_options[option_index].name);
202 else
203 fprintf(stderr, "-%c", opt);
e6b64cd0 204 fprintf(stderr, " would set mdadm mode to \"%s\", but it is already set to \"%s\".\n",
e0d19036
NB
205 map_num(modes, newmode),
206 map_num(modes, mode));
207 exit(2);
208 } else if (!mode && newmode) {
209 mode = newmode;
210 } else {
211 /* special case of -c --help */
212 if (opt == 'c' &&
213 ( strncmp(optarg, "--h", 3)==0 ||
214 strncmp(optarg, "-h", 2)==0)) {
215 fputs(Help_config, stderr);
216 exit(0);
cd29a5c8 217 }
0320ea45
NB
218
219 /* If first option is a device, don't force the mode yet */
220 if (opt == 1) {
221 if (devs_found == 0) {
222 dv = malloc(sizeof(*dv));
223 if (dv == NULL) {
224 fprintf(stderr, Name ": malloc failed\n");
225 exit(3);
226 }
227 dv->devname = optarg;
228 dv->disposition = devmode;
dfd4d8ee 229 dv->writemostly = writemostly;
fe80f49b 230 dv->re_add = re_add;
0320ea45
NB
231 dv->next = NULL;
232 *devlistend = dv;
233 devlistend = &dv->next;
234
235 devs_found++;
236 continue;
237 }
238 /* No mode yet, and this is the second device ... */
239 fprintf(stderr, Name ": An option must be given to set the mode before a second device is listed\n");
240 exit(2);
241 }
e0d19036 242 if (option_index >= 0)
0320ea45 243 fprintf(stderr, Name ": --%s", long_options[option_index].name);
e0d19036 244 else
0320ea45
NB
245 fprintf(stderr, Name ": -%c", opt);
246 fprintf(stderr, " does not set the mode, and so cannot be the first option.\n");
e0d19036
NB
247 exit(2);
248 }
249
250 /* if we just set the mode, then done */
251 switch(opt) {
252 case '@':
253 case '#':
254 case 'A':
255 case 'B':
256 case 'C':
257 case 'F':
dd0781e5 258 case 'G':
e0d19036
NB
259 continue;
260 }
261 if (opt == 1) {
262 /* an undecorated option - must be a device name.
263 */
cd29a5c8 264 if (devs_found > 0 && mode == '@' && !devmode) {
dd0781e5 265 fprintf(stderr, Name ": Must give one of -a/-r/-f for subsequent devices at %s\n", optarg);
52826846
NB
266 exit(2);
267 }
e5329c37
NB
268 if (devs_found > 0 && mode == 'G' && !devmode) {
269 fprintf(stderr, Name ": Must give one of -a for devices do add: %s\n", optarg);
270 exit(2);
271 }
cd29a5c8
NB
272 dv = malloc(sizeof(*dv));
273 if (dv == NULL) {
274 fprintf(stderr, Name ": malloc failed\n");
275 exit(3);
276 }
277 dv->devname = optarg;
278 dv->disposition = devmode;
dfd4d8ee 279 dv->writemostly = writemostly;
fe80f49b 280 dv->re_add = re_add;
cd29a5c8
NB
281 dv->next = NULL;
282 *devlistend = dv;
283 devlistend = &dv->next;
284
52826846
NB
285 devs_found++;
286 continue;
682c7051 287 }
682c7051 288
52826846
NB
289 /* We've got a mode, and opt is now something else which
290 * could depend on the mode */
291#define O(a,b) ((a<<8)|b)
292 switch (O(mode,opt)) {
e0d19036
NB
293 case O(CREATE,'c'):
294 case O(BUILD,'c'): /* chunk or rounding */
52826846
NB
295 if (chunk) {
296 fprintf(stderr, Name ": chunk/rounding may only be specified once. "
297 "Second value is %s.\n", optarg);
298 exit(2);
299 }
300 chunk = strtol(optarg, &c, 10);
301 if (!optarg[0] || *c || chunk<4 || ((chunk-1)&chunk)) {
302 fprintf(stderr, Name ": invalid chunk/rounding value: %s\n",
303 optarg);
304 exit(2);
305 }
306 continue;
64c4757e 307
f9ce90ba
NB
308 case O(CREATE,'e'):
309 case O(ASSEMBLE,'e'):
310 case O(MISC,'e'): /* set metadata (superblock) information */
311 if (ss) {
312 fprintf(stderr, Name ": metadata information already given\n");
313 exit(2);
314 }
82d9eba6
NB
315 for(i=0; !ss && superlist[i]; i++)
316 ss = superlist[i]->match_metadata_desc(optarg);
317
f9ce90ba
NB
318 if (!ss) {
319 fprintf(stderr, Name ": unrecognised metadata identifier: %s\n", optarg);
320 exit(2);
321 }
ea329559 322 max_disks = ss->max_devs;
f9ce90ba
NB
323 continue;
324
dfd4d8ee
NB
325 case O(MANAGE,'W'):
326 case O(BUILD,'W'):
327 case O(CREATE,'W'):
328 /* set write-mostly for following devices */
329 writemostly = 1;
330 continue;
331
dd0781e5 332 case O(GROW,'z'):
e0d19036 333 case O(CREATE,'z'): /* size */
dd0781e5 334 if (size >= 0) {
52826846
NB
335 fprintf(stderr, Name ": size may only be specified once. "
336 "Second value is %s.\n", optarg);
337 exit(2);
338 }
dd0781e5
NB
339 if (strcmp(optarg, "max")==0)
340 size = 0;
341 else {
5dd497ee 342 size = strtoll(optarg, &c, 10);
dd0781e5
NB
343 if (!optarg[0] || *c || size < 4) {
344 fprintf(stderr, Name ": invalid size: %s\n",
345 optarg);
346 exit(2);
347 }
52826846
NB
348 }
349 continue;
64c4757e 350
b5e64645 351 case O(GROW,'l'): /* hack - needed to understand layout */
e0d19036
NB
352 case O(CREATE,'l'):
353 case O(BUILD,'l'): /* set raid level*/
98c6faba 354 if (level != UnSet) {
52826846
NB
355 fprintf(stderr, Name ": raid level may only be set once. "
356 "Second value is %s.\n", optarg);
357 exit(2);
358 }
359 level = map_name(pers, optarg);
98c6faba 360 if (level == UnSet) {
52826846
NB
361 fprintf(stderr, Name ": invalid raid level: %s\n",
362 optarg);
363 exit(2);
364 }
b5e64645 365 if (level != 0 && level != -1 && level != 1 && level != -4 && level != -5 && mode == BUILD) {
52826846
NB
366 fprintf(stderr, Name ": Raid level %s not permitted with --build.\n",
367 optarg);
368 exit(2);
369 }
e0d19036 370 if (sparedisks > 0 && level < 1 && level >= -1) {
b83d95f3 371 fprintf(stderr, Name ": raid level %s is incompatible with spare-devices setting.\n",
52826846
NB
372 optarg);
373 exit(2);
374 }
cd29a5c8 375 ident.level = level;
52826846 376 continue;
64c4757e 377
e0d19036 378 case O(CREATE,'p'): /* raid5 layout */
b5e64645
NB
379 case O(BUILD,'p'): /* faulty layout */
380 case O(GROW, 'p'): /* faulty reconfig */
e5329c37 381 if (layout != UnSet) {
52826846
NB
382 fprintf(stderr,Name ": layout may only be sent once. "
383 "Second value was %s\n", optarg);
384 exit(2);
385 }
386 switch(level) {
387 default:
56eb10c0 388 fprintf(stderr, Name ": layout not meaningful for %s arrays.\n",
52826846
NB
389 map_num(pers, level));
390 exit(2);
98c6faba 391 case UnSet:
52826846
NB
392 fprintf(stderr, Name ": raid level must be given before layout.\n");
393 exit(2);
394
395 case 5:
98c6faba 396 case 6:
52826846 397 layout = map_name(r5layout, optarg);
98c6faba 398 if (layout==UnSet) {
52826846
NB
399 fprintf(stderr, Name ": layout %s not understood for raid5.\n",
400 optarg);
401 exit(2);
402 }
403 break;
e5329c37
NB
404
405 case 10:
b578481c
NB
406 /* 'f', 'o' or 'n' followed by a number <= raid_disks */
407 if ((optarg[0] != 'n' && optarg[0] != 'f' && optarg[0] != 'o') ||
e5329c37
NB
408 (copies = strtoul(optarg+1, &cp, 10)) < 1 ||
409 copies > 200 ||
410 *cp) {
b578481c 411 fprintf(stderr, Name ": layout for raid10 must be 'nNN', 'oNN' or 'fNN' where NN is a number, not %s\n", optarg);
e5329c37
NB
412 exit(2);
413 }
414 if (optarg[0] == 'n')
415 layout = 256 + copies;
b578481c
NB
416 else if (optarg[0] == 'o')
417 layout = 0x10000 + (copies<<8) + 1;
e5329c37
NB
418 else
419 layout = 1 + (copies<<8);
420 break;
b5e64645
NB
421 case -5: /* Faulty
422 * modeNNN
423 */
424
425 {
426 int ln = strcspn(optarg, "0123456789");
427 char *m = strdup(optarg);
428 int mode;
429 m[ln] = 0;
430 mode = map_name(faultylayout, m);
431 if (mode == UnSet) {
432 fprintf(stderr, Name ": layout %s not understood for faulty.\n",
433 optarg);
434 exit(2);
435 }
436 layout = mode | (atoi(optarg+ln)<< ModeShift);
437 }
52826846
NB
438 }
439 continue;
440
dd0781e5
NB
441 case O(CREATE,3):
442 case O(BUILD,3): /* assume clean */
443 assume_clean = 1;
444 continue;
445
446 case O(GROW,'n'):
e0d19036
NB
447 case O(CREATE,'n'):
448 case O(BUILD,'n'): /* number of raid disks */
52826846 449 if (raiddisks) {
b83d95f3 450 fprintf(stderr, Name ": raid-devices set twice: %d and %s\n",
52826846
NB
451 raiddisks, optarg);
452 exit(2);
453 }
454 raiddisks = strtol(optarg, &c, 10);
e4c4352e 455 if (!optarg[0] || *c || raiddisks<=0) {
b83d95f3 456 fprintf(stderr, Name ": invalid number of raid devices: %s\n",
52826846
NB
457 optarg);
458 exit(2);
459 }
cd29a5c8 460 ident.raid_disks = raiddisks;
52826846
NB
461 continue;
462
e0d19036 463 case O(CREATE,'x'): /* number of spare (eXtra) discs */
52826846 464 if (sparedisks) {
b83d95f3 465 fprintf(stderr,Name ": spare-devices set twice: %d and %s\n",
52826846
NB
466 sparedisks, optarg);
467 exit(2);
468 }
98c6faba 469 if (level != UnSet && level <= 0 && level >= -1) {
b83d95f3 470 fprintf(stderr, Name ": spare-devices setting is incompatible with raid level %d\n",
52826846
NB
471 level);
472 exit(2);
473 }
474 sparedisks = strtol(optarg, &c, 10);
e4c4352e 475 if (!optarg[0] || *c || sparedisks < 0) {
b83d95f3 476 fprintf(stderr, Name ": invalid number of spare-devices: %s\n",
52826846
NB
477 optarg);
478 exit(2);
479 }
480 continue;
dd0781e5
NB
481
482 case O(CREATE,'a'):
483 case O(BUILD,'a'):
484 case O(ASSEMBLE,'a'): /* auto-creation of device node */
485 if (optarg == NULL)
8d80900b 486 autof = -2;
dd0781e5
NB
487 else if (strcasecmp(optarg,"no")==0)
488 autof = 0;
8d80900b
NB
489 else if (strcasecmp(optarg,"yes")==0)
490 autof = -2;
491 else if (strcasecmp(optarg,"md")==0)
dd0781e5
NB
492 autof = -1;
493 else {
494 /* There might be digits, and maybe a hypen, at the end */
495 char *e = optarg + strlen(optarg);
496 int num = 4;
497 int len;
498 while (e > optarg && isdigit(e[-1]))
499 e--;
500 if (*e) {
501 num = atoi(e);
502 if (num <= 0) num = 1;
503 }
504 if (e > optarg && e[-1] == '-')
505 e--;
506 len = e - optarg;
507 if ((len == 3 && strncasecmp(optarg,"mdp",3)==0) ||
508 (len == 1 && strncasecmp(optarg,"p",1)==0) ||
509 (len >= 4 && strncasecmp(optarg,"part",4)==0))
510 autof = num;
511 else {
512 fprintf(stderr, Name ": --auto flag arg of \"%s\" unrecognised: use no,yes,md,mdp,part\n"
513 " optionally followed by a number.\n",
514 optarg);
515 exit(2);
516 }
517 }
518 continue;
519
aa88f531 520 case O(BUILD,'f'): /* force honouring '-n 1' */
bd72c2b2 521 case O(GROW,'f'): /* ditto */
e0d19036
NB
522 case O(CREATE,'f'): /* force honouring of device list */
523 case O(ASSEMBLE,'f'): /* force assembly */
524 case O(MISC,'f'): /* force zero */
52826846
NB
525 force=1;
526 continue;
527
528 /* now for the Assemble options */
e0d19036 529 case O(ASSEMBLE,'u'): /* uuid of array */
52826846 530 if (ident.uuid_set) {
cd29a5c8 531 fprintf(stderr, Name ": uuid cannot be set twice. "
52826846
NB
532 "Second value %s.\n", optarg);
533 exit(2);
534 }
535 if (parse_uuid(optarg, ident.uuid))
536 ident.uuid_set = 1;
537 else {
538 fprintf(stderr,Name ": Bad uuid: %s\n", optarg);
539 exit(2);
540 }
541 continue;
542
947fd4dd
NB
543 case O(CREATE,'N'):
544 case O(ASSEMBLE,'N'):
545 if (ident.name[0]) {
546 fprintf(stderr, Name ": name cannot be set twice. "
547 "Second value %s.\n", optarg);
548 exit(2);
549 }
550 if (strlen(optarg) > 32) {
551 fprintf(stderr, Name ": name '%s' is too long, 32 chars max.\n",
552 optarg);
553 exit(2);
554 }
555 strcpy(ident.name, optarg);
556 continue;
557
e0d19036 558 case O(ASSEMBLE,'m'): /* super-minor for array */
98c6faba 559 if (ident.super_minor != UnSet) {
cd29a5c8
NB
560 fprintf(stderr, Name ": super-minor cannot be set twice. "
561 "Second value: %s.\n", optarg);
562 exit(2);
563 }
d013a55e
NB
564 if (strcmp(optarg, "dev")==0)
565 ident.super_minor = -2;
566 else {
567 ident.super_minor = strtoul(optarg, &cp, 10);
568 if (!optarg[0] || *cp) {
569 fprintf(stderr, Name ": Bad super-minor number: %s.\n", optarg);
570 exit(2);
571 }
cd29a5c8
NB
572 }
573 continue;
574
5787fa49
NB
575 case O(ASSEMBLE,'U'): /* update the superblock */
576 if (update) {
577 fprintf(stderr, Name ": Can only update one aspect of superblock, both %s and %s given.\n",
578 update, optarg);
579 exit(2);
580 }
581 update = optarg;
e5329c37
NB
582 if (strcmp(update, "sparc2.2")==0)
583 continue;
5787fa49
NB
584 if (strcmp(update, "super-minor") == 0)
585 continue;
feb716e9
NB
586 if (strcmp(update, "summaries")==0)
587 continue;
e5329c37
NB
588 if (strcmp(update, "resync")==0)
589 continue;
7d99579f
NB
590 if (strcmp(update, "uuid")==0)
591 continue;
586ed405
NB
592 if (strcmp(update, "byteorder")==0) {
593 if (ss) {
594 fprintf(stderr, Name ": must not set metadata type with --update=byteorder.\n");
595 exit(2);
596 }
597 for(i=0; !ss && superlist[i]; i++)
598 ss = superlist[i]->match_metadata_desc("0.swap");
599 if (!ss) {
600 fprintf(stderr, Name ": INTERNAL ERROR cannot find 0.swap\n");
601 exit(2);
602 }
603
604 continue;
605 }
7d99579f 606 fprintf(stderr, Name ": '--update %s' invalid. Only 'sparc2.2', 'super-minor', 'uuid', 'resync' or 'summaries' supported\n",update);
5787fa49
NB
607 exit(2);
608
e0d19036 609 case O(ASSEMBLE,'c'): /* config file */
2d465520 610 case O(MISC, 'c'):
e0d19036 611 case O(MONITOR,'c'):
52826846
NB
612 if (configfile) {
613 fprintf(stderr, Name ": configfile cannot be set twice. "
614 "Second value is %s.\n", optarg);
615 exit(2);
616 }
617 configfile = optarg;
618 /* FIXME possibly check that config file exists. Even parse it */
619 continue;
e0d19036
NB
620 case O(ASSEMBLE,'s'): /* scan */
621 case O(MISC,'s'):
622 case O(MONITOR,'s'):
52826846
NB
623 scan = 1;
624 continue;
625
e0d19036 626 case O(MONITOR,'m'): /* mail address */
52826846
NB
627 if (mailaddr)
628 fprintf(stderr, Name ": only specify one mailaddress. %s ignored.\n",
629 optarg);
630 else
631 mailaddr = optarg;
632 continue;
633
e0d19036 634 case O(MONITOR,'p'): /* alert program */
52826846
NB
635 if (program)
636 fprintf(stderr, Name ": only specify one alter program. %s ignored.\n",
637 optarg);
638 else
639 program = optarg;
640 continue;
64c4757e 641
e0d19036 642 case O(MONITOR,'d'): /* delay in seconds */
f5e166fe 643 case O(GROW, 'd'):
c82f047c
NB
644 case O(BUILD,'d'): /* delay for bitmap updates */
645 case O(CREATE,'d'):
52826846
NB
646 if (delay)
647 fprintf(stderr, Name ": only specify delay once. %s ignored.\n",
648 optarg);
649 else {
650 delay = strtol(optarg, &c, 10);
651 if (!optarg[0] || *c || delay<1) {
652 fprintf(stderr, Name ": invalid delay: %s\n",
653 optarg);
654 exit(2);
655 }
656 }
657 continue;
d013a55e
NB
658 case O(MONITOR,'f'): /* daemonise */
659 daemonise = 1;
660 continue;
b5e64645
NB
661 case O(MONITOR,'i'): /* pid */
662 if (pidfile)
663 fprintf(stderr, Name ": only specify one pid file. %s ignored.\n",
664 optarg);
665 else
666 pidfile = optarg;
667 continue;
aa88f531
NB
668 case O(MONITOR,'1'): /* oneshot */
669 oneshot = 1;
670 continue;
98c6faba
NB
671 case O(MONITOR,'t'): /* test */
672 test = 1;
673 continue;
773135f5
NB
674 case O(MONITOR,'y'): /* log messages to syslog */
675 openlog("mdadm", 0, SYSLOG_FACILITY);
676 dosyslog = 1;
677 continue;
52826846
NB
678
679 /* now the general management options. Some are applicable
680 * to other modes. None have arguments.
681 */
e5329c37 682 case O(GROW,'a'):
dd0781e5 683 case O(MANAGE,'a'): /* add a drive */
52826846 684 devmode = 'a';
fe80f49b
NB
685 re_add = 0;
686 continue;
687 case O(MANAGE,6):
688 devmode = 'a';
689 re_add = 1;
52826846 690 continue;
e0d19036 691 case O(MANAGE,'r'): /* remove a drive */
52826846
NB
692 devmode = 'r';
693 continue;
e0d19036 694 case O(MANAGE,'f'): /* set faulty */
52826846
NB
695 devmode = 'f';
696 continue;
e0d19036
NB
697 case O(MANAGE,'R'):
698 case O(ASSEMBLE,'R'):
699 case O(BUILD,'R'):
700 case O(CREATE,'R'): /* Run the array */
52826846
NB
701 if (runstop < 0) {
702 fprintf(stderr, Name ": Cannot both Stop and Run an array\n");
703 exit(2);
704 }
705 runstop = 1;
706 continue;
e0d19036 707 case O(MANAGE,'S'):
52826846
NB
708 if (runstop > 0) {
709 fprintf(stderr, Name ": Cannot both Run and Stop an array\n");
710 exit(2);
711 }
712 runstop = -1;
713 continue;
714
e0d19036 715 case O(MANAGE,'o'):
52826846
NB
716 if (readonly < 0) {
717 fprintf(stderr, Name ": Cannot have both readonly and readwrite\n");
718 exit(2);
719 }
720 readonly = 1;
721 continue;
e0d19036 722 case O(MANAGE,'w'):
52826846 723 if (readonly > 0) {
e0d19036 724 fprintf(stderr, Name ": Cannot have both readwrite and readonly.\n");
52826846
NB
725 exit(2);
726 }
727 readonly = -1;
728 continue;
e0d19036
NB
729
730 case O(MISC,'Q'):
731 case O(MISC,'D'):
732 case O(MISC,'E'):
733 case O(MISC,'K'):
734 case O(MISC,'R'):
735 case O(MISC,'S'):
c82f047c 736 case O(MISC,'X'):
e0d19036
NB
737 case O(MISC,'o'):
738 case O(MISC,'w'):
739 if (devmode && devmode != opt &&
740 (devmode == 'E' || (opt == 'E' && devmode != 'Q'))) {
741 fprintf(stderr, Name ": --examine/-E cannot be given with -%c\n",
742 devmode =='E'?opt:devmode);
743 exit(2);
744 }
745 devmode = opt;
746 continue;
feb716e9
NB
747 case O(MISC,'t'):
748 test = 1;
749 continue;
e0d19036 750
bd526cee
NB
751 case O(MISC, 22):
752 if (devmode != 'E') {
753 fprintf(stderr, Name ": --sparc2.2 only allowed with --examine\n");
754 exit(2);
755 }
756 SparcAdjust = 1;
757 continue;
c82f047c
NB
758
759 case O(ASSEMBLE,'b'): /* here we simply set the bitmap file */
760 if (!optarg) {
761 fprintf(stderr, Name ": bitmap file needed with -b in --assemble mode\n");
762 exit(2);
763 }
55935d51
NB
764 if (strcmp(optarg, "internal")==0) {
765 fprintf(stderr, Name ": there is no need to specify --bitmap when assembling arrays with internal bitmaps\n");
766 continue;
767 }
c82f047c
NB
768 bitmap_fd = open(optarg, O_RDWR);
769 if (!*optarg || bitmap_fd < 0) {
770 fprintf(stderr, Name ": cannot open bitmap file %s: %s\n", optarg, strerror(errno));
771 exit(2);
772 }
773 ident.bitmap_fd = bitmap_fd; /* for Assemble */
774 continue;
f5e166fe 775
06b0d786
NB
776 case O(ASSEMBLE, 7):
777 case O(GROW, 7):
778 /* Specify a file into which grow might place a backup,
779 * or from which assemble might recover a backup
780 */
781 if (backup_file) {
782 fprintf(stderr, Name ": backup file already specified, rejecting %s\n", optarg);
783 exit(2);
784 }
785 backup_file = optarg;
786 continue;
787
f5e166fe 788 case O(GROW,'b'):
c82f047c
NB
789 case O(BUILD,'b'):
790 case O(CREATE,'b'): /* here we create the bitmap */
1e0d770c
NB
791 if (strcmp(optarg, "internal")== 0 ||
792 strcmp(optarg, "none")== 0 ||
793 strchr(optarg, '/') != NULL) {
794 bitmap_file = optarg;
795 continue;
796 }
797 /* probable typo */
798 fprintf(stderr, Name ": bitmap file must contain a '/', or be 'internal', or 'none'\n");
799 exit(2);
c82f047c 800
f5e166fe 801 case O(GROW,4):
c82f047c
NB
802 case O(BUILD,4):
803 case O(CREATE,4): /* bitmap chunksize */
804 bitmap_chunk = strtol(optarg, &c, 10);
805 if (!optarg[0] || *c || bitmap_chunk < 0 ||
806 bitmap_chunk & (bitmap_chunk - 1)) {
807 fprintf(stderr, Name ": invalid bitmap chunksize: %s\n",
808 optarg);
809 exit(2);
810 }
811 /* convert K to B, chunk of 0K means 512B */
812 bitmap_chunk = bitmap_chunk ? bitmap_chunk * 1024 : 512;
813 continue;
dfd4d8ee
NB
814
815 case O(BUILD, 5):
816 case O(CREATE, 5): /* write-behind mode */
817 write_behind = DEFAULT_MAX_WRITE_BEHIND;
818 if (optarg) {
819 write_behind = strtol(optarg, &c, 10);
820 if (write_behind < 0 || *c ||
821 write_behind > 16383) {
822 fprintf(stderr, Name ": Invalid value for maximum outstanding write-behind writes: %s.\n\tMust be between 0 and 16383.\n", optarg);
823 exit(2);
824 }
825 }
826 continue;
52826846
NB
827 }
828 /* We have now processed all the valid options. Anything else is
829 * an error
830 */
06b0d786
NB
831 if (option_index > 0)
832 fprintf(stderr, Name ":option --%s not valid in %s mode\n",
833 long_options[option_index].name,
834 map_num(modes, mode));
835 else
836 fprintf(stderr, Name ": option -%c not valid in %s mode\n",
837 opt, map_num(modes, mode));
64c4757e 838 exit(2);
52826846
NB
839
840 }
841
3d4064cc
NB
842 if (print_help) {
843 char *help_text = Help;
844 if (print_help == 2)
845 help_text = OptionHelp;
846 else
847 switch (mode) {
848 case ASSEMBLE : help_text = Help_assemble; break;
849 case BUILD : help_text = Help_build; break;
850 case CREATE : help_text = Help_create; break;
851 case MANAGE : help_text = Help_manage; break;
852 case MISC : help_text = Help_misc; break;
853 case MONITOR : help_text = Help_monitor; break;
854 case GROW : help_text = Help_grow; break;
855 }
856 fputs(help_text,stderr);
857 exit(0);
858 }
859
0320ea45
NB
860 if (!mode && devs_found) {
861 mode = MISC;
862 devmode = 'Q';
863 if (devlist->disposition == 0)
864 devlist->disposition = devmode;
865 }
52826846
NB
866 if (!mode) {
867 fputs(Usage, stderr);
64c4757e 868 exit(2);
64c4757e 869 }
52826846
NB
870 /* Ok, got the option parsing out of the way
871 * hopefully it's mostly right but there might be some stuff
872 * missing
873 *
e0d19036 874 * That is mosty checked in the per-mode stuff but...
52826846
NB
875 *
876 * For @,B,C and A without -s, the first device listed must be an md device
877 * we check that here and open it.
64c4757e 878 */
52826846 879
dd0781e5
NB
880 if (mode==MANAGE || mode == BUILD || mode == CREATE || mode == GROW ||
881 (mode == ASSEMBLE && ! scan)) {
52826846
NB
882 if (devs_found < 1) {
883 fprintf(stderr, Name ": an md device must be given in this mode\n");
884 exit(2);
885 }
dd0781e5
NB
886 if ((int)ident.super_minor == -2 && autof) {
887 fprintf(stderr, Name ": --super-minor=dev is incompatible with --auto\n");
888 exit(2);
889 }
890 mdfd = open_mddev(devlist->devname, autof);
52826846
NB
891 if (mdfd < 0)
892 exit(1);
98c6faba 893 if ((int)ident.super_minor == -2) {
d013a55e
NB
894 struct stat stb;
895 fstat(mdfd, &stb);
0df46c2a 896 ident.super_minor = minor(stb.st_rdev);
d013a55e 897 }
64c4757e 898 }
52826846 899
e4c4352e
NB
900 if (raiddisks) {
901 if (raiddisks > max_disks) {
6fbba4c9
NB
902 fprintf(stderr, Name ": invalid number of raid devices: %d\n",
903 raiddisks);
e4c4352e
NB
904 exit(2);
905 }
906 if (raiddisks == 1 && !force && level != -5) {
907 fprintf(stderr, Name ": '1' is an unusual number of drives for an array, so it is probably\n"
908 " a mistake. If you really mean it you will need to specify --force before\n"
909 " setting the number of drives.\n");
910 exit(2);
911 }
912 }
913 if (sparedisks) {
914 if ( sparedisks > max_disks - raiddisks) {
6fbba4c9
NB
915 fprintf(stderr, Name ": invalid number of spare-devices: %d\n",
916 sparedisks);
e4c4352e
NB
917 exit(2);
918 }
919 }
c82f047c 920
52826846
NB
921 rv = 0;
922 switch(mode) {
e0d19036 923 case MANAGE:
52826846
NB
924 /* readonly, add/remove, readwrite, runstop */
925 if (readonly>0)
cd29a5c8 926 rv = Manage_ro(devlist->devname, mdfd, readonly);
52826846 927 if (!rv && devs_found>1)
cd29a5c8 928 rv = Manage_subdevs(devlist->devname, mdfd,
dab6685f 929 devlist->next, verbose-quiet);
52826846 930 if (!rv && readonly < 0)
cd29a5c8 931 rv = Manage_ro(devlist->devname, mdfd, readonly);
52826846 932 if (!rv && runstop)
91f068bf 933 rv = Manage_runstop(devlist->devname, mdfd, runstop, 0);
52826846 934 break;
e0d19036 935 case ASSEMBLE:
d013a55e 936 if (devs_found == 1 && ident.uuid_set == 0 &&
947fd4dd 937 ident.super_minor == UnSet && ident.name[0] == 0 && !scan ) {
d013a55e
NB
938 /* Only a device has been given, so get details from config file */
939 mddev_ident_t array_ident = conf_get_ident(configfile, devlist->devname);
b5e64645
NB
940 if (array_ident == NULL) {
941 fprintf(stderr, Name ": %s not identified in config file.\n",
942 devlist->devname);
d013a55e 943 rv |= 1;
b5e64645 944 } else {
1337546d
NB
945 mdfd = open_mddev(devlist->devname,
946 array_ident->autof ? array_ident->autof : autof);
b5e64645 947 if (mdfd < 0)
d013a55e 948 rv |= 1;
b5e64645 949 else {
f9ce90ba 950 rv |= Assemble(ss, devlist->devname, mdfd, array_ident, configfile,
06b0d786 951 NULL, backup_file,
dab6685f 952 readonly, runstop, update, verbose-quiet, force);
b5e64645
NB
953 close(mdfd);
954 }
d013a55e
NB
955 }
956 } else if (!scan)
f9ce90ba 957 rv = Assemble(ss, devlist->devname, mdfd, &ident, configfile,
06b0d786 958 devlist->next, backup_file,
dab6685f 959 readonly, runstop, update, verbose-quiet, force);
5787fa49
NB
960 else if (devs_found>0) {
961 if (update && devs_found > 1) {
962 fprintf(stderr, Name ": can only update a single array at a time\n");
963 exit(1);
964 }
06b0d786
NB
965 if (backup_file && devs_found > 1) {
966 fprintf(stderr, Name ": can only assemble a single array when providing a backup file.\n");
967 exit(1);
968 }
cd29a5c8
NB
969 for (dv = devlist ; dv ; dv=dv->next) {
970 mddev_ident_t array_ident = conf_get_ident(configfile, dv->devname);
52826846
NB
971 if (array_ident == NULL) {
972 fprintf(stderr, Name ": %s not identified in config file.\n",
cd29a5c8 973 dv->devname);
52826846
NB
974 rv |= 1;
975 continue;
976 }
1337546d
NB
977 mdfd = open_mddev(dv->devname,
978 array_ident->autof ?array_ident->autof : autof);
b5e64645
NB
979 if (mdfd < 0) {
980 rv |= 1;
981 continue;
982 }
f9ce90ba 983 rv |= Assemble(ss, dv->devname, mdfd, array_ident, configfile,
06b0d786 984 NULL, backup_file,
dab6685f 985 readonly, runstop, update, verbose-quiet, force);
b5e64645 986 close(mdfd);
52826846 987 }
5787fa49 988 } else {
52826846
NB
989 mddev_ident_t array_list = conf_get_ident(configfile, NULL);
990 if (!array_list) {
991 fprintf(stderr, Name ": No arrays found in config file\n");
992 rv = 1;
993 } else
06b0d786
NB
994 if (update) {
995 fprintf(stderr, Name ": --update not meaningful with a --scan assembly.\n");
996 exit(1);
997 }
998 if (backup_file) {
999 fprintf(stderr, Name ": --backup_file not meaningful with a --scan assembly.\n");
1000 exit(1);
1001 }
52826846 1002 for (; array_list; array_list = array_list->next) {
cd29a5c8 1003 mdu_array_info_t array;
1337546d
NB
1004 mdfd = open_mddev(array_list->devname,
1005 array_list->autof ? array_list->autof : autof);
52826846
NB
1006 if (mdfd < 0) {
1007 rv |= 1;
1008 continue;
1009 }
cd29a5c8
NB
1010 if (ioctl(mdfd, GET_ARRAY_INFO, &array)>=0)
1011 /* already assembled, skip */
43fc1676
NB
1012 ;
1013 else
f9ce90ba 1014 rv |= Assemble(ss, array_list->devname, mdfd,
43fc1676 1015 array_list, configfile,
06b0d786 1016 NULL, NULL,
dab6685f 1017 readonly, runstop, NULL, verbose-quiet, force);
43fc1676 1018 close(mdfd);
52826846
NB
1019 }
1020 }
1021 break;
e0d19036 1022 case BUILD:
c82f047c 1023 if (delay == 0) delay = DEFAULT_BITMAP_DELAY;
dfd4d8ee
NB
1024 if (write_behind && !bitmap_file) {
1025 fprintf(stderr, Name ": write-behind mode requires a bitmap.\n");
1026 rv = 1;
1027 break;
1028 }
1029
c82f047c 1030 if (bitmap_file) {
55935d51
NB
1031 if (strcmp(bitmap_file, "internal")==0) {
1032 fprintf(stderr, Name ": 'internal' bitmaps not supported with --build\n");
1033 rv |= 1;
1034 break;
1035 }
c82f047c
NB
1036 }
1037 rv = Build(devlist->devname, mdfd, chunk, level, layout,
1038 raiddisks, devlist->next, assume_clean,
dab6685f 1039 bitmap_file, bitmap_chunk, write_behind, delay, verbose-quiet);
52826846 1040 break;
e0d19036 1041 case CREATE:
c82f047c 1042 if (delay == 0) delay = DEFAULT_BITMAP_DELAY;
dfd4d8ee
NB
1043 if (write_behind && !bitmap_file) {
1044 fprintf(stderr, Name ": write-behind mode requires a bitmap.\n");
1045 rv = 1;
1046 break;
1047 }
f9ce90ba
NB
1048
1049 rv = Create(ss, devlist->devname, mdfd, chunk, level, layout, size<0 ? 0 : size,
947fd4dd 1050 raiddisks, sparedisks, ident.name,
47d79ef8 1051 devs_found-1, devlist->next, runstop, verbose-quiet, force, assume_clean,
dfd4d8ee 1052 bitmap_file, bitmap_chunk, write_behind, delay);
52826846 1053 break;
e0d19036
NB
1054 case MISC:
1055
1056 if (devmode == 'E') {
1057 if (devlist == NULL && !scan) {
1058 fprintf(stderr, Name ": No devices to examine\n");
1059 exit(2);
1060 }
1061 if (devlist == NULL)
1062 devlist = conf_get_devs(configfile);
1063 if (devlist == NULL) {
c913b90e 1064 fprintf(stderr, Name ": No devices listed in %s\n", configfile?configfile:DefaultConfFile);
e0d19036
NB
1065 exit(1);
1066 }
22892d56 1067 rv = Examine(devlist, scan?(verbose>1?0:verbose+1):brief, scan, SparcAdjust, ss);
e0d19036
NB
1068 } else {
1069 if (devlist == NULL) {
91f068bf
NB
1070 if (devmode=='D' && scan) {
1071 /* apply --detail to all devices in /proc/mdstat */
22a88995 1072 struct mdstat_ent *ms = mdstat_read(0, 1);
e0d19036
NB
1073 struct mdstat_ent *e;
1074 for (e=ms ; e ; e=e->next) {
1075 char *name = get_md_name(e->devnum);
1076
1077 if (!name) {
1078 fprintf(stderr, Name ": cannot find device file for %s\n",
1079 e->dev);
1080 continue;
1081 }
22892d56 1082 rv |= Detail(name, verbose>1?0:verbose+1, test);
91f068bf
NB
1083 put_md_name(name);
1084 }
1085 } else if (devmode == 'S' && scan) {
1086 /* apply --stop to all devices in /proc/mdstat */
1087 /* Due to possible stacking of devices, repeat until
1088 * nothing more can be stopped
1089 */
1090 int progress=1, err;
1091 int last = 0;
1092 do {
22a88995 1093 struct mdstat_ent *ms = mdstat_read(0, 0);
91f068bf
NB
1094 struct mdstat_ent *e;
1095
1096 if (!progress) last = 1;
1097 progress = 0; err = 0;
1098 for (e=ms ; e ; e=e->next) {
1099 char *name = get_md_name(e->devnum);
1100
1101 if (!name) {
1102 fprintf(stderr, Name ": cannot find device file for %s\n",
1103 e->dev);
1104 continue;
1105 }
dd0781e5 1106 mdfd = open_mddev(name, 0);
43fc1676 1107 if (mdfd >= 0) {
91f068bf
NB
1108 if (Manage_runstop(name, mdfd, -1, !last))
1109 err = 1;
1110 else
1111 progress = 1;
43fc1676
NB
1112 close(mdfd);
1113 }
91f068bf
NB
1114
1115 put_md_name(name);
e0d19036 1116 }
91f068bf 1117 } while (!last && err);
f9c25f1d 1118 if (err) rv |= 1;
91f068bf 1119 } else {
e0d19036
NB
1120 fprintf(stderr, Name ": No devices given.\n");
1121 exit(2);
1122 }
1123 }
1124 for (dv=devlist ; dv; dv=dv->next) {
1125 switch(dv->disposition) {
1126 case 'D':
22892d56 1127 rv |= Detail(dv->devname, brief?1+verbose:0, test); continue;
e0d19036 1128 case 'K': /* Zero superblock */
6409687b 1129 rv |= Kill(dv->devname, force, quiet); continue;
e0d19036
NB
1130 case 'Q':
1131 rv |= Query(dv->devname); continue;
c82f047c 1132 case 'X':
55935d51 1133 rv |= ExamineBitmap(dv->devname, brief, ss); continue;
e0d19036 1134 }
dd0781e5 1135 mdfd = open_mddev(dv->devname, 0);
43fc1676 1136 if (mdfd>=0) {
e0d19036
NB
1137 switch(dv->disposition) {
1138 case 'R':
91f068bf 1139 rv |= Manage_runstop(dv->devname, mdfd, 1, 0); break;
e0d19036 1140 case 'S':
91f068bf 1141 rv |= Manage_runstop(dv->devname, mdfd, -1, 0); break;
e0d19036
NB
1142 case 'o':
1143 rv |= Manage_ro(dv->devname, mdfd, 1); break;
1144 case 'w':
1145 rv |= Manage_ro(dv->devname, mdfd, -1); break;
1146 }
43fc1676 1147 close(mdfd);
7f48e210
NB
1148 } else
1149 rv |= 1;
e0d19036 1150 }
cd29a5c8 1151 }
9a9dab36 1152 break;
e0d19036 1153 case MONITOR:
e0d19036
NB
1154 if (!devlist && !scan) {
1155 fprintf(stderr, Name ": Cannot monitor: need --scan or at least one device\n");
1156 rv = 1;
1157 break;
1158 }
b5e64645
NB
1159 if (pidfile && !daemonise) {
1160 fprintf(stderr, Name ": Cannot write a pid file when not in daemon mode\n");
1161 rv = 1;
1162 break;
1163 }
d013a55e 1164 rv= Monitor(devlist, mailaddr, program,
773135f5
NB
1165 delay?delay:60, daemonise, scan, oneshot,
1166 dosyslog, configfile, test, pidfile);
9a9dab36 1167 break;
dd0781e5
NB
1168
1169 case GROW:
1170 if (devs_found > 1) {
e5329c37
NB
1171
1172 /* must be '-a'. */
1173 if (size >= 0 || raiddisks) {
1174 fprintf(stderr, Name ": --size, --raiddisks, and --add are exclusing in --grow mode\n");
1175 rv = 1;
1176 break;
1177 }
1178 for (dv=devlist->next; dv ; dv=dv->next) {
1179 rv = Grow_Add_device(devlist->devname, mdfd, dv->devname);
1180 if (rv)
1181 break;
1182 }
f5e166fe
NB
1183 } else if ((size >= 0) + (raiddisks != 0) + (layout != UnSet) + (bitmap_file != NULL)> 1) {
1184 fprintf(stderr, Name ": can change at most one of size, raiddisks, bitmap, and layout\n");
dd0781e5
NB
1185 rv = 1;
1186 break;
b5e64645
NB
1187 } else if (layout != UnSet)
1188 rv = Manage_reconfig(devlist->devname, mdfd, layout);
1189 else if (size >= 0 || raiddisks)
06b0d786 1190 rv = Grow_reshape(devlist->devname, mdfd, quiet, backup_file,
e86c9dd6 1191 size, level, layout, chunk, raiddisks);
f5e166fe
NB
1192 else if (bitmap_file) {
1193 if (delay == 0) delay = DEFAULT_BITMAP_DELAY;
1194 rv = Grow_addbitmap(devlist->devname, mdfd, bitmap_file,
8fac0577 1195 bitmap_chunk, delay, write_behind, force);
f5e166fe 1196 } else
b5e64645 1197 fprintf(stderr, Name ": no changes to --grow\n");
dd0781e5 1198 break;
64c4757e 1199 }
52826846 1200 exit(rv);
64c4757e 1201}