summaryrefslogtreecommitdiffstats
path: root/mdadm.c
diff options
context:
space:
mode:
authorNeil Brown <neilb@suse.de>2006-01-30 00:13:26 +0000
committerNeil Brown <neilb@suse.de>2006-01-30 00:13:26 +0000
commit3d4064cc9bfa49f9aa933eb4d8164fe437ecda04 (patch)
tree7673159d5abce41c58b80b9e98678bdf22e8750e /mdadm.c
parentb674b5b86926a346b9692884f3aa3eb66f669c69 (diff)
downloadmdadm-3d4064cc9bfa49f9aa933eb4d8164fe437ecda04.tar.gz
mdadm-3d4064cc9bfa49f9aa933eb4d8164fe437ecda04.tar.xz
mdadm-3d4064cc9bfa49f9aa933eb4d8164fe437ecda04.zip
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>
Diffstat (limited to 'mdadm.c')
-rw-r--r--mdadm.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/mdadm.c b/mdadm.c
index 64e895e..4174f92 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -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';