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