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;
int dosyslog = 0;
int copies;
+ int print_help = 0;
int mdfd = -1;
/* 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 (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);
}
+ 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,
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;
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;