2 * mdadm - manage Linux "md" devices aka RAID arrays.
4 * Copyright (C) 2001-2002 Neil Brown <neilb@cse.unsw.edu.au>
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.
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.
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
22 * Email: <neilb@cse.unsw.edu.au>
24 * School of Computer Science and Engineering
25 * The University of New South Wales
29 * Additions for bitmap and async RAID options, Copyright (C) 2003-2004,
30 * Paul Clements, SteelEye Technology, Inc.
38 int main(int argc
, char *argv
[])
54 struct mddev_ident_s ident
;
55 char *configfile
= NULL
;
63 char *bitmap_file
= NULL
;
64 int bitmap_chunk
= UnSet
;
66 mddev_dev_t devlist
= NULL
;
67 mddev_dev_t
*devlistend
= & devlist
;
75 int autof
= 0; /* -2 means create device based on name:
76 * if it ends mdN, then non-partitioned array N
77 * if it ends dN, then partitions array N
78 * -1 means create non-partitioned, choose N
79 * 1 or more to create partitioned
80 * If -1 or 1 and name is a 'standard' name, then
81 * insist on a match of type and number.
84 char *mailaddr
= NULL
;
90 struct supertype
*ss
= NULL
;
96 srandom(time(0) ^ getpid());
100 ident
.raid_disks
= UnSet
;
101 ident
.super_minor
= UnSet
;
103 ident
.spare_group
= NULL
;
106 ident
.bitmap_fd
= -1;
108 while ((option_index
= -1) ,
109 (opt
=getopt_long(argc
, argv
,
110 short_options
, long_options
,
111 &option_index
)) != -1) {
113 /* firstly, so mode-independant options */
117 if (option_index
> 0 &&
118 strcmp(long_options
[option_index
].name
, "help-options")==0)
119 help_text
= OptionHelp
;
122 case ASSEMBLE
: help_text
= Help_assemble
; break;
123 case BUILD
: help_text
= Help_build
; break;
124 case CREATE
: help_text
= Help_create
; break;
125 case MANAGE
: help_text
= Help_manage
; break;
126 case MISC
: help_text
= Help_misc
; break;
127 case MONITOR
: help_text
= Help_monitor
; break;
128 case GROW
: help_text
= Help_grow
; break;
130 fputs(help_text
,stderr
);
134 fputs(Version
, stderr
);
137 case 'v': verbose
= 1;
141 if (mode
== ASSEMBLE
|| mode
== BUILD
|| mode
== CREATE
|| mode
== GROW
)
142 break; /* b means bitmap */
148 fputs(Usage
, stderr
);
151 /* second, figure out the mode.
152 * Some options force the mode. Others
153 * set the mode if it isn't already
157 case '@': /* just incase they say --manage */
158 newmode
= MANAGE
; break;
162 if (!mode
) newmode
= MANAGE
;
165 case 'A': newmode
= ASSEMBLE
; break;
166 case 'B': newmode
= BUILD
; break;
167 case 'C': newmode
= CREATE
; break;
168 case 'F': newmode
= MONITOR
;break;
169 case 'G': newmode
= GROW
; break;
175 case 'Q': newmode
= MISC
; break;
180 case 'K': if (!mode
) newmode
= MISC
; break;
182 if (mode
&& newmode
== mode
) {
183 /* everybody happy ! */
184 } else if (mode
&& newmode
!= mode
) {
186 fprintf(stderr
, Name
": ");
187 if (option_index
>= 0)
188 fprintf(stderr
, "--%s", long_options
[option_index
].name
);
190 fprintf(stderr
, "-%c", opt
);
191 fprintf(stderr
, " would set mdadm mode to \"%s\", but it is already set to \"%s\".\n",
192 map_num(modes
, newmode
),
193 map_num(modes
, mode
));
195 } else if (!mode
&& newmode
) {
198 /* special case of -c --help */
200 ( strncmp(optarg
, "--h", 3)==0 ||
201 strncmp(optarg
, "-h", 2)==0)) {
202 fputs(Help_config
, stderr
);
206 /* If first option is a device, don't force the mode yet */
208 if (devs_found
== 0) {
209 dv
= malloc(sizeof(*dv
));
211 fprintf(stderr
, Name
": malloc failed\n");
214 dv
->devname
= optarg
;
215 dv
->disposition
= devmode
;
218 devlistend
= &dv
->next
;
223 /* No mode yet, and this is the second device ... */
224 fprintf(stderr
, Name
": An option must be given to set the mode before a second device is listed\n");
227 if (option_index
>= 0)
228 fprintf(stderr
, Name
": --%s", long_options
[option_index
].name
);
230 fprintf(stderr
, Name
": -%c", opt
);
231 fprintf(stderr
, " does not set the mode, and so cannot be the first option.\n");
235 /* if we just set the mode, then done */
247 /* an undecorated option - must be a device name.
249 if (devs_found
> 0 && mode
== '@' && !devmode
) {
250 fprintf(stderr
, Name
": Must give one of -a/-r/-f for subsequent devices at %s\n", optarg
);
253 if (devs_found
> 0 && mode
== 'G' && !devmode
) {
254 fprintf(stderr
, Name
": Must give one of -a for devices do add: %s\n", optarg
);
257 dv
= malloc(sizeof(*dv
));
259 fprintf(stderr
, Name
": malloc failed\n");
262 dv
->devname
= optarg
;
263 dv
->disposition
= devmode
;
266 devlistend
= &dv
->next
;
272 /* We've got a mode, and opt is now something else which
273 * could depend on the mode */
274 #define O(a,b) ((a<<8)|b)
275 switch (O(mode
,opt
)) {
277 case O(BUILD
,'c'): /* chunk or rounding */
279 fprintf(stderr
, Name
": chunk/rounding may only be specified once. "
280 "Second value is %s.\n", optarg
);
283 chunk
= strtol(optarg
, &c
, 10);
284 if (!optarg
[0] || *c
|| chunk
<4 || ((chunk
-1)&chunk
)) {
285 fprintf(stderr
, Name
": invalid chunk/rounding value: %s\n",
292 case O(ASSEMBLE
,'e'):
293 case O(MISC
,'e'): /* set metadata (superblock) information */
295 fprintf(stderr
, Name
": metadata information already given\n");
298 for(i
=0; !ss
&& superlist
[i
]; i
++)
299 ss
= superlist
[i
]->match_metadata_desc(optarg
);
302 fprintf(stderr
, Name
": unrecognised metadata identifier: %s\n", optarg
);
308 case O(CREATE
,'z'): /* size */
310 fprintf(stderr
, Name
": size may only be specified once. "
311 "Second value is %s.\n", optarg
);
314 if (strcmp(optarg
, "max")==0)
317 size
= strtol(optarg
, &c
, 10);
318 if (!optarg
[0] || *c
|| size
< 4) {
319 fprintf(stderr
, Name
": invalid size: %s\n",
326 case O(GROW
,'l'): /* hack - needed to understand layout */
328 case O(BUILD
,'l'): /* set raid level*/
329 if (level
!= UnSet
) {
330 fprintf(stderr
, Name
": raid level may only be set once. "
331 "Second value is %s.\n", optarg
);
334 level
= map_name(pers
, optarg
);
335 if (level
== UnSet
) {
336 fprintf(stderr
, Name
": invalid raid level: %s\n",
340 if (level
!= 0 && level
!= -1 && level
!= 1 && level
!= -4 && level
!= -5 && mode
== BUILD
) {
341 fprintf(stderr
, Name
": Raid level %s not permitted with --build.\n",
345 if (sparedisks
> 0 && level
< 1 && level
>= -1) {
346 fprintf(stderr
, Name
": raid level %s is incompatible with spare-devices setting.\n",
353 case O(CREATE
,'p'): /* raid5 layout */
354 case O(BUILD
,'p'): /* faulty layout */
355 case O(GROW
, 'p'): /* faulty reconfig */
356 if (layout
!= UnSet
) {
357 fprintf(stderr
,Name
": layout may only be sent once. "
358 "Second value was %s\n", optarg
);
363 fprintf(stderr
, Name
": layout not meaningful for %s arrays.\n",
364 map_num(pers
, level
));
367 fprintf(stderr
, Name
": raid level must be given before layout.\n");
372 layout
= map_name(r5layout
, optarg
);
374 fprintf(stderr
, Name
": layout %s not understood for raid5.\n",
381 /* 'f' or 'n' followed by a number <= raid_disks */
382 if ((optarg
[0] != 'n' && optarg
[0] != 'f') ||
383 (copies
= strtoul(optarg
+1, &cp
, 10)) < 1 ||
386 fprintf(stderr
, Name
": layout for raid10 must be 'nNN' or 'fNN' where NN is a number, not %s\n", optarg
);
389 if (optarg
[0] == 'n')
390 layout
= 256 + copies
;
392 layout
= 1 + (copies
<<8);
399 int ln
= strcspn(optarg
, "0123456789");
400 char *m
= strdup(optarg
);
403 mode
= map_name(faultylayout
, m
);
405 fprintf(stderr
, Name
": layout %s not understood for faulty.\n",
409 layout
= mode
| (atoi(optarg
+ln
)<< ModeShift
);
415 case O(BUILD
,3): /* assume clean */
421 case O(BUILD
,'n'): /* number of raid disks */
423 fprintf(stderr
, Name
": raid-devices set twice: %d and %s\n",
427 raiddisks
= strtol(optarg
, &c
, 10);
428 if (!optarg
[0] || *c
|| raiddisks
<=0 || raiddisks
> MD_SB_DISKS
) {
429 fprintf(stderr
, Name
": invalid number of raid devices: %s\n",
433 if (raiddisks
== 1 && !force
&& level
!= -5) {
434 fprintf(stderr
, Name
": '1' is an unusual number of drives for an array, so it is probably\n"
435 " a mistake. If you really mean it you will need to specify --force before\n"
436 " setting the number of drives.\n");
439 ident
.raid_disks
= raiddisks
;
442 case O(CREATE
,'x'): /* number of spare (eXtra) discs */
444 fprintf(stderr
,Name
": spare-devices set twice: %d and %s\n",
448 if (level
!= UnSet
&& level
<= 0 && level
>= -1) {
449 fprintf(stderr
, Name
": spare-devices setting is incompatible with raid level %d\n",
453 sparedisks
= strtol(optarg
, &c
, 10);
454 if (!optarg
[0] || *c
|| sparedisks
< 0 || sparedisks
> MD_SB_DISKS
- raiddisks
) {
455 fprintf(stderr
, Name
": invalid number of spare-devices: %s\n",
463 case O(ASSEMBLE
,'a'): /* auto-creation of device node */
466 else if (strcasecmp(optarg
,"no")==0)
468 else if (strcasecmp(optarg
,"yes")==0)
470 else if (strcasecmp(optarg
,"md")==0)
473 /* There might be digits, and maybe a hypen, at the end */
474 char *e
= optarg
+ strlen(optarg
);
477 while (e
> optarg
&& isdigit(e
[-1]))
481 if (num
<= 0) num
= 1;
483 if (e
> optarg
&& e
[-1] == '-')
486 if ((len
== 3 && strncasecmp(optarg
,"mdp",3)==0) ||
487 (len
== 1 && strncasecmp(optarg
,"p",1)==0) ||
488 (len
>= 4 && strncasecmp(optarg
,"part",4)==0))
491 fprintf(stderr
, Name
": --auto flag arg of \"%s\" unrecognised: use no,yes,md,mdp,part\n"
492 " optionally followed by a number.\n",
499 case O(BUILD
,'f'): /* force honouring '-n 1' */
500 case O(CREATE
,'f'): /* force honouring of device list */
501 case O(ASSEMBLE
,'f'): /* force assembly */
502 case O(MISC
,'f'): /* force zero */
506 /* now for the Assemble options */
507 case O(ASSEMBLE
,'u'): /* uuid of array */
508 if (ident
.uuid_set
) {
509 fprintf(stderr
, Name
": uuid cannot be set twice. "
510 "Second value %s.\n", optarg
);
513 if (parse_uuid(optarg
, ident
.uuid
))
516 fprintf(stderr
,Name
": Bad uuid: %s\n", optarg
);
521 case O(ASSEMBLE
,'m'): /* super-minor for array */
522 if (ident
.super_minor
!= UnSet
) {
523 fprintf(stderr
, Name
": super-minor cannot be set twice. "
524 "Second value: %s.\n", optarg
);
527 if (strcmp(optarg
, "dev")==0)
528 ident
.super_minor
= -2;
530 ident
.super_minor
= strtoul(optarg
, &cp
, 10);
531 if (!optarg
[0] || *cp
) {
532 fprintf(stderr
, Name
": Bad super-minor number: %s.\n", optarg
);
538 case O(ASSEMBLE
,'U'): /* update the superblock */
540 fprintf(stderr
, Name
": Can only update one aspect of superblock, both %s and %s given.\n",
545 if (strcmp(update
, "sparc2.2")==0)
547 if (strcmp(update
, "super-minor") == 0)
549 if (strcmp(update
, "summaries")==0)
551 if (strcmp(update
, "resync")==0)
553 fprintf(stderr
, Name
": '--update %s' invalid. Only 'sparc2.2', 'super-minor', 'resync' or 'summaries' supported\n",update
);
556 case O(ASSEMBLE
,'c'): /* config file */
560 fprintf(stderr
, Name
": configfile cannot be set twice. "
561 "Second value is %s.\n", optarg
);
565 /* FIXME possibly check that config file exists. Even parse it */
567 case O(ASSEMBLE
,'s'): /* scan */
573 case O(MONITOR
,'m'): /* mail address */
575 fprintf(stderr
, Name
": only specify one mailaddress. %s ignored.\n",
581 case O(MONITOR
,'p'): /* alert program */
583 fprintf(stderr
, Name
": only specify one alter program. %s ignored.\n",
589 case O(MONITOR
,'d'): /* delay in seconds */
591 case O(BUILD
,'d'): /* delay for bitmap updates */
594 fprintf(stderr
, Name
": only specify delay once. %s ignored.\n",
597 delay
= strtol(optarg
, &c
, 10);
598 if (!optarg
[0] || *c
|| delay
<1) {
599 fprintf(stderr
, Name
": invalid delay: %s\n",
605 case O(MONITOR
,'f'): /* daemonise */
608 case O(MONITOR
,'i'): /* pid */
610 fprintf(stderr
, Name
": only specify one pid file. %s ignored.\n",
615 case O(MONITOR
,'1'): /* oneshot */
618 case O(MONITOR
,'t'): /* test */
622 /* now the general management options. Some are applicable
623 * to other modes. None have arguments.
626 case O(MANAGE
,'a'): /* add a drive */
629 case O(MANAGE
,'r'): /* remove a drive */
632 case O(MANAGE
,'f'): /* set faulty */
636 case O(ASSEMBLE
,'R'):
638 case O(CREATE
,'R'): /* Run the array */
640 fprintf(stderr
, Name
": Cannot both Stop and Run an array\n");
647 fprintf(stderr
, Name
": Cannot both Run and Stop an array\n");
655 fprintf(stderr
, Name
": Cannot have both readonly and readwrite\n");
662 fprintf(stderr
, Name
": Cannot have both readwrite and readonly.\n");
677 if (devmode
&& devmode
!= opt
&&
678 (devmode
== 'E' || (opt
== 'E' && devmode
!= 'Q'))) {
679 fprintf(stderr
, Name
": --examine/-E cannot be given with -%c\n",
680 devmode
=='E'?opt
:devmode
);
690 if (devmode
!= 'E') {
691 fprintf(stderr
, Name
": --sparc2.2 only allowed with --examine\n");
697 case O(ASSEMBLE
,'b'): /* here we simply set the bitmap file */
699 fprintf(stderr
, Name
": bitmap file needed with -b in --assemble mode\n");
702 if (strcmp(optarg
, "internal")==0) {
703 fprintf(stderr
, Name
": there is no need to specify --bitmap when assembling arrays with internal bitmaps\n");
706 bitmap_fd
= open(optarg
, O_RDWR
);
707 if (!*optarg
|| bitmap_fd
< 0) {
708 fprintf(stderr
, Name
": cannot open bitmap file %s: %s\n", optarg
, strerror(errno
));
711 ident
.bitmap_fd
= bitmap_fd
; /* for Assemble */
716 case O(CREATE
,'b'): /* here we create the bitmap */
717 bitmap_file
= optarg
;
722 case O(CREATE
,4): /* bitmap chunksize */
723 bitmap_chunk
= strtol(optarg
, &c
, 10);
724 if (!optarg
[0] || *c
|| bitmap_chunk
< 0 ||
725 bitmap_chunk
& (bitmap_chunk
- 1)) {
726 fprintf(stderr
, Name
": invalid bitmap chunksize: %s\n",
730 /* convert K to B, chunk of 0K means 512B */
731 bitmap_chunk
= bitmap_chunk
? bitmap_chunk
* 1024 : 512;
734 /* We have now processed all the valid options. Anything else is
737 fprintf(stderr
, Name
": option %c not valid in %s mode\n",
738 opt
, map_num(modes
, mode
));
743 if (!mode
&& devs_found
) {
746 if (devlist
->disposition
== 0)
747 devlist
->disposition
= devmode
;
750 fputs(Usage
, stderr
);
753 /* Ok, got the option parsing out of the way
754 * hopefully it's mostly right but there might be some stuff
757 * That is mosty checked in the per-mode stuff but...
759 * For @,B,C and A without -s, the first device listed must be an md device
760 * we check that here and open it.
763 if (mode
==MANAGE
|| mode
== BUILD
|| mode
== CREATE
|| mode
== GROW
||
764 (mode
== ASSEMBLE
&& ! scan
)) {
765 if (devs_found
< 1) {
766 fprintf(stderr
, Name
": an md device must be given in this mode\n");
769 if ((int)ident
.super_minor
== -2 && autof
) {
770 fprintf(stderr
, Name
": --super-minor=dev is incompatible with --auto\n");
773 mdfd
= open_mddev(devlist
->devname
, autof
);
776 if ((int)ident
.super_minor
== -2) {
779 ident
.super_minor
= minor(stb
.st_rdev
);
787 /* readonly, add/remove, readwrite, runstop */
789 rv
= Manage_ro(devlist
->devname
, mdfd
, readonly
);
790 if (!rv
&& devs_found
>1)
791 rv
= Manage_subdevs(devlist
->devname
, mdfd
,
793 if (!rv
&& readonly
< 0)
794 rv
= Manage_ro(devlist
->devname
, mdfd
, readonly
);
796 rv
= Manage_runstop(devlist
->devname
, mdfd
, runstop
);
799 if (devs_found
== 1 && ident
.uuid_set
== 0 &&
800 ident
.super_minor
== UnSet
&& !scan
) {
801 /* Only a device has been given, so get details from config file */
802 mddev_ident_t array_ident
= conf_get_ident(configfile
, devlist
->devname
);
803 if (array_ident
== NULL
) {
804 fprintf(stderr
, Name
": %s not identified in config file.\n",
808 mdfd
= open_mddev(devlist
->devname
, array_ident
->autof
);
812 rv
|= Assemble(ss
, devlist
->devname
, mdfd
, array_ident
, configfile
,
814 readonly
, runstop
, update
, verbose
, force
);
819 rv
= Assemble(ss
, devlist
->devname
, mdfd
, &ident
, configfile
,
821 readonly
, runstop
, update
, verbose
, force
);
822 else if (devs_found
>0) {
823 if (update
&& devs_found
> 1) {
824 fprintf(stderr
, Name
": can only update a single array at a time\n");
827 for (dv
= devlist
; dv
; dv
=dv
->next
) {
828 mddev_ident_t array_ident
= conf_get_ident(configfile
, dv
->devname
);
829 if (array_ident
== NULL
) {
830 fprintf(stderr
, Name
": %s not identified in config file.\n",
835 mdfd
= open_mddev(dv
->devname
, array_ident
->autof
);
840 rv
|= Assemble(ss
, dv
->devname
, mdfd
, array_ident
, configfile
,
842 readonly
, runstop
, update
, verbose
, force
);
846 mddev_ident_t array_list
= conf_get_ident(configfile
, NULL
);
848 fprintf(stderr
, Name
": No arrays found in config file\n");
851 for (; array_list
; array_list
= array_list
->next
) {
852 mdu_array_info_t array
;
853 mdfd
= open_mddev(array_list
->devname
, array_list
->autof
);
858 if (ioctl(mdfd
, GET_ARRAY_INFO
, &array
)>=0)
859 /* already assembled, skip */
862 rv
|= Assemble(ss
, array_list
->devname
, mdfd
,
863 array_list
, configfile
,
865 readonly
, runstop
, NULL
, verbose
, force
);
871 if (bitmap_chunk
== UnSet
) bitmap_chunk
= DEFAULT_BITMAP_CHUNK
;
872 if (delay
== 0) delay
= DEFAULT_BITMAP_DELAY
;
874 if (strcmp(bitmap_file
, "internal")==0) {
875 fprintf(stderr
, Name
": 'internal' bitmaps not supported with --build\n");
879 bitmap_fd
= open(bitmap_file
, O_RDWR
,0);
880 if (bitmap_fd
< 0 && errno
!= ENOENT
) {
881 perror(Name
": cannot create bitmap file");
886 bitmap_fd
= CreateBitmap(bitmap_file
, force
, NULL
,
887 bitmap_chunk
, delay
, size
);
890 rv
= Build(devlist
->devname
, mdfd
, chunk
, level
, layout
,
891 raiddisks
, devlist
->next
, assume_clean
,
892 bitmap_file
, bitmap_chunk
, delay
);
895 if (delay
== 0) delay
= DEFAULT_BITMAP_DELAY
;
897 for(i
=0; !ss
&& superlist
[i
]; i
++)
898 ss
= superlist
[i
]->match_metadata_desc("default");
901 fprintf(stderr
, Name
": internal error - no default metadata style\n");
905 rv
= Create(ss
, devlist
->devname
, mdfd
, chunk
, level
, layout
, size
<0 ? 0 : size
,
906 raiddisks
, sparedisks
,
907 devs_found
-1, devlist
->next
, runstop
, verbose
, force
,
908 bitmap_file
, bitmap_chunk
, delay
);
912 if (devmode
== 'E') {
913 if (devlist
== NULL
&& !scan
) {
914 fprintf(stderr
, Name
": No devices to examine\n");
918 devlist
= conf_get_devs(configfile
);
919 if (devlist
== NULL
) {
920 fprintf(stderr
, Name
": No devices listed in %s\n", configfile
?configfile
:DefaultConfFile
);
923 rv
= Examine(devlist
, scan
?!verbose
:brief
, scan
, SparcAdjust
, ss
);
925 if (devlist
== NULL
) {
926 if ((devmode
== 'S' ||devmode
=='D') && scan
) {
927 /* apply to all devices in /proc/mdstat */
928 struct mdstat_ent
*ms
= mdstat_read(0);
929 struct mdstat_ent
*e
;
930 if (devmode
== 'S') {
931 /* reverse order so that arrays made of arrays are stopped properly */
932 struct mdstat_ent
*sm
= NULL
;
933 while ((e
=ms
) != NULL
) {
940 for (e
=ms
; e
; e
=e
->next
) {
941 char *name
= get_md_name(e
->devnum
);
944 fprintf(stderr
, Name
": cannot find device file for %s\n",
949 rv
|= Detail(name
, !verbose
, test
);
950 else if (devmode
=='S') {
951 mdfd
= open_mddev(name
, 0);
953 rv
|= Manage_runstop(name
, mdfd
, -1);
960 fprintf(stderr
, Name
": No devices given.\n");
964 for (dv
=devlist
; dv
; dv
=dv
->next
) {
965 switch(dv
->disposition
) {
967 rv
|= Detail(dv
->devname
, brief
, test
); continue;
968 case 'K': /* Zero superblock */
969 rv
|= Kill(dv
->devname
, force
); continue;
971 rv
|= Query(dv
->devname
); continue;
973 rv
|= ExamineBitmap(dv
->devname
, brief
, ss
); continue;
975 mdfd
= open_mddev(dv
->devname
, 0);
977 switch(dv
->disposition
) {
979 rv
|= Manage_runstop(dv
->devname
, mdfd
, 1); break;
981 rv
|= Manage_runstop(dv
->devname
, mdfd
, -1); break;
983 rv
|= Manage_ro(dv
->devname
, mdfd
, 1); break;
985 rv
|= Manage_ro(dv
->devname
, mdfd
, -1); break;
993 if (!devlist
&& !scan
) {
994 fprintf(stderr
, Name
": Cannot monitor: need --scan or at least one device\n");
998 if (pidfile
&& !daemonise
) {
999 fprintf(stderr
, Name
": Cannot write a pid file when not in daemon mode\n");
1003 rv
= Monitor(devlist
, mailaddr
, program
,
1004 delay
?delay
:60, daemonise
, scan
, oneshot
, configfile
, test
, pidfile
);
1008 if (devs_found
> 1) {
1011 if (size
>= 0 || raiddisks
) {
1012 fprintf(stderr
, Name
": --size, --raiddisks, and --add are exclusing in --grow mode\n");
1016 for (dv
=devlist
->next
; dv
; dv
=dv
->next
) {
1017 rv
= Grow_Add_device(devlist
->devname
, mdfd
, dv
->devname
);
1021 } else if ((size
>= 0) + (raiddisks
!= 0) + (layout
!= UnSet
) + (bitmap_file
!= NULL
)> 1) {
1022 fprintf(stderr
, Name
": can change at most one of size, raiddisks, bitmap, and layout\n");
1025 } else if (layout
!= UnSet
)
1026 rv
= Manage_reconfig(devlist
->devname
, mdfd
, layout
);
1027 else if (size
>= 0 || raiddisks
)
1028 rv
= Manage_resize(devlist
->devname
, mdfd
, size
, raiddisks
);
1029 else if (bitmap_file
) {
1030 if (delay
== 0) delay
= DEFAULT_BITMAP_DELAY
;
1031 rv
= Grow_addbitmap(devlist
->devname
, mdfd
, bitmap_file
,
1032 bitmap_chunk
, delay
);
1034 fprintf(stderr
, Name
": no changes to --grow\n");