summaryrefslogtreecommitdiff
path: root/usr/src/cmd/zpool/zpool_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/cmd/zpool/zpool_main.c')
-rw-r--r--usr/src/cmd/zpool/zpool_main.c46
1 files changed, 35 insertions, 11 deletions
diff --git a/usr/src/cmd/zpool/zpool_main.c b/usr/src/cmd/zpool/zpool_main.c
index 2ec75731ec..29db529458 100644
--- a/usr/src/cmd/zpool/zpool_main.c
+++ b/usr/src/cmd/zpool/zpool_main.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2011 Joyent, Inc. All rights reserved.
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2011 by Delphix. All rights reserved.
* Copyright (c) 2012 by Frederik Wessels. All rights reserved.
@@ -221,7 +222,7 @@ get_usage(zpool_help_t idx) {
return (gettext("\tiostat [-v] [-T d|u] [pool] ... [interval "
"[count]]\n"));
case HELP_LIST:
- return (gettext("\tlist [-H] [-o property[,...]] "
+ return (gettext("\tlist [-Hp] [-o property[,...]] "
"[-T d|u] [pool] ... [interval [count]]\n"));
case HELP_OFFLINE:
return (gettext("\toffline [-t] <pool> <device> ...\n"));
@@ -242,7 +243,7 @@ get_usage(zpool_help_t idx) {
"\tupgrade -v\n"
"\tupgrade [-V version] <-a | pool ...>\n"));
case HELP_GET:
- return (gettext("\tget <\"all\" | property[,...]> "
+ return (gettext("\tget [-p] <\"all\" | property[,...]> "
"<pool> ...\n"));
case HELP_SET:
return (gettext("\tset <property=value> <pool> \n"));
@@ -2456,6 +2457,7 @@ zpool_do_iostat(int argc, char **argv)
typedef struct list_cbdata {
boolean_t cb_scripted;
boolean_t cb_first;
+ boolean_t cb_literal;
zprop_list_t *cb_proplist;
} list_cbdata_t;
@@ -2497,7 +2499,8 @@ print_header(zprop_list_t *pl)
* to the described layout.
*/
static void
-print_pool(zpool_handle_t *zhp, zprop_list_t *pl, int scripted)
+print_pool(zpool_handle_t *zhp, zprop_list_t *pl, int scripted,
+ boolean_t literal)
{
boolean_t first = B_TRUE;
char property[ZPOOL_MAXPROPLEN];
@@ -2518,7 +2521,7 @@ print_pool(zpool_handle_t *zhp, zprop_list_t *pl, int scripted)
right_justify = B_FALSE;
if (pl->pl_prop != ZPROP_INVAL) {
if (zpool_get_prop(zhp, pl->pl_prop, property,
- sizeof (property), NULL) != 0)
+ sizeof (property), NULL, literal) != 0)
propstr = "-";
else
propstr = property;
@@ -2560,18 +2563,19 @@ list_callback(zpool_handle_t *zhp, void *data)
cbp->cb_first = B_FALSE;
}
- print_pool(zhp, cbp->cb_proplist, cbp->cb_scripted);
+ print_pool(zhp, cbp->cb_proplist, cbp->cb_scripted, cbp->cb_literal);
return (0);
}
/*
- * zpool list [-H] [-o prop[,prop]*] [-T d|u] [pool] ... [interval [count]]
+ * zpool list [-Hp] [-o prop[,prop]*] [-T d|u] [pool] ... [interval [count]]
*
* -H Scripted mode. Don't display headers, and separate properties
* by a single tab.
* -o List of properties to display. Defaults to
* "name,size,allocated,free,capacity,health,altroot"
+ * -p Display values in parsable (literal) format.
* -T Display a timestamp in date(1) or Unix format
*
* List all pools in the system, whether or not they're healthy. Output space
@@ -2589,7 +2593,7 @@ zpool_do_list(int argc, char **argv)
unsigned long interval = 0, count = 0;
/* check options */
- while ((c = getopt(argc, argv, ":Ho:T:")) != -1) {
+ while ((c = getopt(argc, argv, ":Hpo:T:")) != -1) {
switch (c) {
case 'H':
cb.cb_scripted = B_TRUE;
@@ -2597,6 +2601,9 @@ zpool_do_list(int argc, char **argv)
case 'o':
props = optarg;
break;
+ case 'p':
+ cb.cb_literal = B_TRUE;
+ break;
case 'T':
get_timestamp_arg(*optarg);
break;
@@ -4354,7 +4361,7 @@ get_callback(zpool_handle_t *zhp, void *data)
continue;
if (zpool_get_prop(zhp, pl->pl_prop,
- value, sizeof (value), &srctype) != 0)
+ value, sizeof (value), &srctype, cbp->cb_literal) != 0)
continue;
zprop_print_one_property(zpool_get_name(zhp), cbp,
@@ -4370,8 +4377,25 @@ zpool_do_get(int argc, char **argv)
zprop_get_cbdata_t cb = { 0 };
zprop_list_t fake_name = { 0 };
int ret;
+ char c;
+
+ /* check options */
+ while ((c = getopt(argc, argv, ":p")) != -1) {
+ switch (c) {
+ case 'p':
+ cb.cb_literal = B_TRUE;
+ break;
+ case '?':
+ (void) fprintf(stderr, gettext("invalid option '%c'\n"),
+ optopt);
+ usage(B_FALSE);
+ }
+ }
+
+ argc -= optind;
+ argv += optind;
- if (argc < 3)
+ if (argc < 2)
usage(B_FALSE);
cb.cb_first = B_TRUE;
@@ -4382,7 +4406,7 @@ zpool_do_get(int argc, char **argv)
cb.cb_columns[3] = GET_COL_SOURCE;
cb.cb_type = ZFS_TYPE_POOL;
- if (zprop_get_list(g_zfs, argv[1], &cb.cb_proplist,
+ if (zprop_get_list(g_zfs, argv[0], &cb.cb_proplist,
ZFS_TYPE_POOL) != 0)
usage(B_FALSE);
@@ -4393,7 +4417,7 @@ zpool_do_get(int argc, char **argv)
cb.cb_proplist = &fake_name;
}
- ret = for_each_pool(argc - 2, argv + 2, B_TRUE, &cb.cb_proplist,
+ ret = for_each_pool(argc - 1, argv + 1, B_TRUE, &cb.cb_proplist,
get_callback, &cb);
if (cb.cb_proplist == &fake_name)