aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/zpool
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/zpool')
-rw-r--r--cmd/zpool/zpool_main.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c
index 6d0dae8d8..d64fdfa5b 100644
--- a/cmd/zpool/zpool_main.c
+++ b/cmd/zpool/zpool_main.c
@@ -126,6 +126,8 @@ static int zpool_do_version(int, char **);
static int zpool_do_wait(int, char **);
+static int zpool_do_help(int argc, char **argv);
+
static zpool_compat_status_t zpool_do_load_compat(
const char *, boolean_t *);
@@ -538,6 +540,10 @@ usage(boolean_t requested)
(void) fprintf(fp, "%s",
get_usage(command_table[i].usage));
}
+
+ (void) fprintf(fp,
+ gettext("\nFor further help on a command or topic, "
+ "run: %s\n"), "zpool help [<topic>]");
} else {
(void) fprintf(fp, gettext("usage:\n"));
(void) fprintf(fp, "%s", get_usage(current_command->usage));
@@ -11051,6 +11057,25 @@ zpool_do_version(int argc, char **argv)
return (zfs_version_print() != 0);
}
+/* Display documentation */
+static int
+zpool_do_help(int argc, char **argv)
+{
+ char page[MAXNAMELEN];
+ if (argc < 3 || strcmp(argv[2], "zpool") == 0)
+ strcpy(page, "zpool");
+ else if (strcmp(argv[2], "concepts") == 0 ||
+ strcmp(argv[2], "props") == 0)
+ snprintf(page, sizeof (page), "zpool%s", argv[2]);
+ else
+ snprintf(page, sizeof (page), "zpool-%s", argv[2]);
+
+ execlp("man", "man", page, NULL);
+
+ fprintf(stderr, "couldn't run man program: %s", strerror(errno));
+ return (-1);
+}
+
/*
* Do zpool_load_compat() and print error message on failure
*/
@@ -11118,6 +11143,12 @@ main(int argc, char **argv)
if ((strcmp(cmdname, "-V") == 0) || (strcmp(cmdname, "--version") == 0))
return (zpool_do_version(argc, argv));
+ /*
+ * Special case 'help'
+ */
+ if (strcmp(cmdname, "help") == 0)
+ return (zpool_do_help(argc, argv));
+
if ((g_zfs = libzfs_init()) == NULL) {
(void) fprintf(stderr, "%s\n", libzfs_error_init(errno));
return (1);