int mode = 0;
int opt;
int option_index;
- char *help_text;
char *c;
int rv;
int i;
int chunk = 0;
- int size = -1;
+ long long size = -1;
int level = UnSet;
int layout = UnSet;
int raiddisks = 0;
struct supertype *ss = NULL;
int writemostly = 0;
int re_add = 0;
+ char *shortopt = short_options;
+ int dosyslog = 0;
int copies;
+ int print_help = 0;
int mdfd = -1;
while ((option_index = -1) ,
(opt=getopt_long(argc, argv,
- short_options, long_options,
+ shortopt, long_options,
&option_index)) != -1) {
int newmode = mode;
/* firstly, some mode-independant options */
switch(opt) {
case 'h':
- help_text = Help;
if (option_index > 0 &&
strcmp(long_options[option_index].name, "help-options")==0)
- help_text = OptionHelp;
+ print_help = 2;
else
- switch (mode) {
- case ASSEMBLE : help_text = Help_assemble; break;
- case BUILD : help_text = Help_build; break;
- case CREATE : help_text = Help_create; break;
- case MANAGE : help_text = Help_manage; break;
- case MISC : help_text = Help_misc; break;
- case MONITOR : help_text = Help_monitor; break;
- case GROW : help_text = Help_grow; break;
- }
- fputs(help_text,stderr);
- exit(0);
+ print_help = 1;
+ continue;
case 'V':
fputs(Version, stderr);
if (mode == ASSEMBLE || mode == BUILD || mode == CREATE || mode == GROW)
break; /* b means bitmap */
brief = 1;
+ if (optarg) {
+ fprintf(stderr, Name ": -b cannot have any extra immediately after it, sorry.\n");
+ exit(2);
+ }
continue;
case ':':
switch(opt) {
case '@': /* just incase they say --manage */
- newmode = MANAGE; break;
+ newmode = MANAGE;
+ shortopt = short_bitmap_auto_options;
+ break;
case 'a':
case 'r':
case 'f':
case 6: /* re-add */
- if (!mode) newmode = MANAGE;
+ if (!mode) {
+ newmode = MANAGE;
+ shortopt = short_bitmap_auto_options;
+ }
break;
- case 'A': newmode = ASSEMBLE; break;
- case 'B': newmode = BUILD; break;
- case 'C': newmode = CREATE; break;
+ case 'A': newmode = ASSEMBLE; shortopt = short_bitmap_auto_options; break;
+ case 'B': newmode = BUILD; shortopt = short_bitmap_auto_options; break;
+ case 'C': newmode = CREATE; shortopt = short_bitmap_auto_options; break;
case 'F': newmode = MONITOR;break;
- case 'G': newmode = GROW; break;
+ case 'G': newmode = GROW; shortopt = short_bitmap_auto_options; break;
case '#':
case 'D':
if (strcmp(optarg, "max")==0)
size = 0;
else {
- size = strtol(optarg, &c, 10);
+ size = strtoll(optarg, &c, 10);
if (!optarg[0] || *c || size < 4) {
fprintf(stderr, Name ": invalid size: %s\n",
optarg);
continue;
if (strcmp(update, "resync")==0)
continue;
+ if (strcmp(update, "uuid")==0)
+ continue;
if (strcmp(update, "byteorder")==0) {
if (ss) {
fprintf(stderr, Name ": must not set metadata type with --update=byteorder.\n");
continue;
}
- fprintf(stderr, Name ": '--update %s' invalid. Only 'sparc2.2', 'super-minor', 'resync' or 'summaries' supported\n",update);
+ fprintf(stderr, Name ": '--update %s' invalid. Only 'sparc2.2', 'super-minor', 'uuid', 'resync' or 'summaries' supported\n",update);
exit(2);
case O(ASSEMBLE,'c'): /* config file */
case O(MONITOR,'t'): /* test */
test = 1;
continue;
+ case O(MONITOR,'y'): /* log messages to syslog */
+ openlog("mdadm", 0, SYSLOG_FACILITY);
+ dosyslog = 1;
+ continue;
/* now the general management options. Some are applicable
* to other modes. None have arguments.
}
+ if (print_help) {
+ char *help_text = Help;
+ if (print_help == 2)
+ help_text = OptionHelp;
+ else
+ switch (mode) {
+ case ASSEMBLE : help_text = Help_assemble; break;
+ case BUILD : help_text = Help_build; break;
+ case CREATE : help_text = Help_create; break;
+ case MANAGE : help_text = Help_manage; break;
+ case MISC : help_text = Help_misc; break;
+ case MONITOR : help_text = Help_monitor; break;
+ case GROW : help_text = Help_grow; break;
+ }
+ fputs(help_text,stderr);
+ exit(0);
+ }
+
if (!mode && devs_found) {
mode = MISC;
devmode = 'Q';
rv = 1;
break;
}
- if (ss == NULL) {
- for(i=0; !ss && superlist[i]; i++)
- ss = superlist[i]->match_metadata_desc("default");
- }
- if (!ss) {
- fprintf(stderr, Name ": internal error - no default metadata style\n");
- exit(2);
- }
rv = Create(ss, devlist->devname, mdfd, chunk, level, layout, size<0 ? 0 : size,
raiddisks, sparedisks, ident.name,
- devs_found-1, devlist->next, runstop, verbose-quiet, force,
+ devs_found-1, devlist->next, runstop, verbose-quiet, force, assume_clean,
bitmap_file, bitmap_chunk, write_behind, delay);
break;
case MISC:
if (devlist == NULL) {
if (devmode=='D' && scan) {
/* apply --detail to all devices in /proc/mdstat */
- struct mdstat_ent *ms = mdstat_read(0);
+ struct mdstat_ent *ms = mdstat_read(0, 1);
struct mdstat_ent *e;
for (e=ms ; e ; e=e->next) {
char *name = get_md_name(e->devnum);
int progress=1, err;
int last = 0;
do {
- struct mdstat_ent *ms = mdstat_read(0);
+ struct mdstat_ent *ms = mdstat_read(0, 0);
struct mdstat_ent *e;
if (!progress) last = 1;
break;
}
rv= Monitor(devlist, mailaddr, program,
- delay?delay:60, daemonise, scan, oneshot, configfile, test, pidfile);
+ delay?delay:60, daemonise, scan, oneshot,
+ dosyslog, configfile, test, pidfile);
break;
case GROW:
else if (bitmap_file) {
if (delay == 0) delay = DEFAULT_BITMAP_DELAY;
rv = Grow_addbitmap(devlist->devname, mdfd, bitmap_file,
- bitmap_chunk, delay, write_behind);
+ bitmap_chunk, delay, write_behind, force);
} else
fprintf(stderr, Name ": no changes to --grow\n");
break;