diff options
Diffstat (limited to 'cddl/contrib/opensolaris/cmd/zpool/zpool_util.c')
-rw-r--r-- | cddl/contrib/opensolaris/cmd/zpool/zpool_util.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/cddl/contrib/opensolaris/cmd/zpool/zpool_util.c b/cddl/contrib/opensolaris/cmd/zpool/zpool_util.c index 8eb9c81..f44da4f 100644 --- a/cddl/contrib/opensolaris/cmd/zpool/zpool_util.c +++ b/cddl/contrib/opensolaris/cmd/zpool/zpool_util.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -77,3 +77,28 @@ zpool_no_memory(void) gettext("internal error: out of memory\n")); exit(1); } + +/* + * Return the number of logs in supplied nvlist + */ +uint_t +num_logs(nvlist_t *nv) +{ + uint_t nlogs = 0; + uint_t c, children; + nvlist_t **child; + + if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_CHILDREN, + &child, &children) != 0) + return (0); + + for (c = 0; c < children; c++) { + uint64_t is_log = B_FALSE; + + (void) nvlist_lookup_uint64(child[c], ZPOOL_CONFIG_IS_LOG, + &is_log); + if (is_log) + nlogs++; + } + return (nlogs); +} |