Support --help --assemble etc.

i.e. allow '--help' to be first and still give
context sensitive help.

Also don't print truncated device-size of very large arrays.

Signed-off-by: Neil Brown <neilb@suse.de>
This commit is contained in:
Neil Brown 2006-01-30 00:13:26 +00:00
parent b674b5b869
commit 3d4064cc9b
2 changed files with 29 additions and 16 deletions

View File

@ -163,8 +163,13 @@ int Detail(char *dev, int brief, int test)
printf(" Raid Level : %s\n", c?c:"-unknown-");
if (larray_size)
printf(" Array Size : %llu%s\n", (larray_size>>10), human_size(larray_size));
if (array.level >= 1)
printf(" Device Size : %d%s\n", array.size, human_size((long long)array.size<<10));
if (array.level >= 1) {
if (array.major_version != 0 &&
larray_size >= 0xFFFFFFFFULL)
printf(" Device Size : unknown\n");
else
printf(" Device Size : %d%s\n", array.size, human_size((long long)array.size<<10));
}
printf(" Raid Devices : %d\n", array.raid_disks);
printf(" Total Devices : %d\n", array.nr_disks);
printf("Preferred Minor : %d\n", array.md_minor);

36
mdadm.c
View File

@ -40,7 +40,6 @@ int main(int argc, char *argv[])
int mode = 0;
int opt;
int option_index;
char *help_text;
char *c;
int rv;
int i;
@ -97,6 +96,7 @@ int main(int argc, char *argv[])
int dosyslog = 0;
int copies;
int print_help = 0;
int mdfd = -1;
@ -121,22 +121,12 @@ int main(int argc, char *argv[])
/* 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);
@ -821,6 +811,24 @@ int main(int argc, char *argv[])
}
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';