aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/libzfs.h2
-rw-r--r--lib/libzfs/libzfs_pool.c20
2 files changed, 19 insertions, 3 deletions
diff --git a/include/libzfs.h b/include/libzfs.h
index 273286ceb..c212a0c05 100644
--- a/include/libzfs.h
+++ b/include/libzfs.h
@@ -281,6 +281,8 @@ extern int zpool_label_disk(libzfs_handle_t *, zpool_handle_t *, char *);
extern int zpool_set_prop(zpool_handle_t *, const char *, const char *);
extern int zpool_get_prop(zpool_handle_t *, zpool_prop_t, char *,
size_t proplen, zprop_source_t *);
+extern int zpool_get_prop_literal(zpool_handle_t *, zpool_prop_t, char *,
+ size_t proplen, zprop_source_t *, boolean_t literal);
extern uint64_t zpool_get_prop_int(zpool_handle_t *, zpool_prop_t,
zprop_source_t *);
diff --git a/lib/libzfs/libzfs_pool.c b/lib/libzfs/libzfs_pool.c
index e8e7efca5..8b3edec16 100644
--- a/lib/libzfs/libzfs_pool.c
+++ b/lib/libzfs/libzfs_pool.c
@@ -236,13 +236,23 @@ zpool_pool_state_to_name(pool_state_t state)
}
/*
- * Get a zpool property value for 'prop' and return the value in
- * a pre-allocated buffer.
+ * API compatibility wrapper around zpool_get_prop_literal
*/
int
zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, size_t len,
zprop_source_t *srctype)
{
+ return zpool_get_prop_literal(zhp, prop, buf, len, srctype, B_FALSE);
+}
+
+/*
+ * Get a zpool property value for 'prop' and return the value in
+ * a pre-allocated buffer.
+ */
+int
+zpool_get_prop_literal(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, size_t len,
+ zprop_source_t *srctype, boolean_t literal)
+{
uint64_t intval;
const char *strval;
zprop_source_t src = ZPROP_SRC_NONE;
@@ -308,7 +318,11 @@ zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, size_t len,
case ZPOOL_PROP_FREEING:
case ZPOOL_PROP_EXPANDSZ:
case ZPOOL_PROP_ASHIFT:
- (void) zfs_nicenum(intval, buf, len);
+ if (literal)
+ (void) snprintf(buf, len, "%llu",
+ (u_longlong_t)intval);
+ else
+ (void) zfs_nicenum(intval, buf, len);
break;
case ZPOOL_PROP_CAPACITY: