Justin T. Gibbs
2011-07-18 02:13:21 UTC
Author: gibbs
Date: Mon Jul 18 02:13:21 2011
New Revision: 224169
URL: http://svn.freebsd.org/changeset/base/224169
Log:
cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h:
cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c:
o Add zpool_pool_state_to_name() API to libzfs which converts a
pool_state_t into a user consumable string.
o While here, correct constness of make zpool_state_to_name()
and zpool_label_disk().
MFD after: 1 week
Modified:
head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h
head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c
Modified: head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
==============================================================================
--- head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c Mon Jul 18 01:09:43 2011 (r224168)
+++ head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c Mon Jul 18 02:13:21 2011 (r224169)
@@ -1052,7 +1052,7 @@ print_status_config(zpool_handle_t *zhp,
char *vname;
uint64_t notpresent;
spare_cbdata_t cb;
- char *state;
+ const char *state;
if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_CHILDREN,
&child, &children) != 0)
Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h
==============================================================================
--- head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h Mon Jul 18 01:09:43 2011 (r224168)
+++ head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h Mon Jul 18 02:13:21 2011 (r224169)
@@ -200,7 +200,8 @@ extern zpool_handle_t *zpool_open_canfai
extern void zpool_close(zpool_handle_t *);
extern const char *zpool_get_name(zpool_handle_t *);
extern int zpool_get_state(zpool_handle_t *);
-extern char *zpool_state_to_name(vdev_state_t, vdev_aux_t);
+extern const char *zpool_state_to_name(vdev_state_t, vdev_aux_t);
+extern const char *zpool_pool_state_to_name(pool_state_t);
extern void zpool_free_handles(libzfs_handle_t *);
/*
@@ -249,7 +250,7 @@ extern nvlist_t *zpool_find_vdev(zpool_h
boolean_t *, boolean_t *);
extern nvlist_t *zpool_find_vdev_by_physpath(zpool_handle_t *, const char *,
boolean_t *, boolean_t *, boolean_t *);
-extern int zpool_label_disk(libzfs_handle_t *, zpool_handle_t *, char *);
+extern int zpool_label_disk(libzfs_handle_t *, zpool_handle_t *, const char *);
/*
* Functions to manage pool properties
Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c
==============================================================================
--- head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c Mon Jul 18 01:09:43 2011 (r224168)
+++ head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c Mon Jul 18 02:13:21 2011 (r224169)
@@ -174,7 +174,7 @@ zpool_get_prop_int(zpool_handle_t *zhp,
/*
* Map VDEV STATE to printed strings.
*/
-char *
+const char *
zpool_state_to_name(vdev_state_t state, vdev_aux_t aux)
{
switch (state) {
@@ -202,6 +202,34 @@ zpool_state_to_name(vdev_state_t state,
}
/*
+ * Map POOL STATE to printed strings.
+ */
+const char *
+zpool_pool_state_to_name(pool_state_t state)
+{
+ switch (state) {
+ case POOL_STATE_ACTIVE:
+ return (gettext("ACTIVE"));
+ case POOL_STATE_EXPORTED:
+ return (gettext("EXPORTED"));
+ case POOL_STATE_DESTROYED:
+ return (gettext("DESTROYED"));
+ case POOL_STATE_SPARE:
+ return (gettext("SPARE"));
+ case POOL_STATE_L2CACHE:
+ return (gettext("L2CACHE"));
+ case POOL_STATE_UNINITIALIZED:
+ return (gettext("UNINITIALIZED"));
+ case POOL_STATE_UNAVAIL:
+ return (gettext("UNAVAIL"));
+ case POOL_STATE_POTENTIALLY_ACTIVE:
+ return (gettext("POTENTIALLY_ACTIVE"));
+ }
+
+ return (gettext("UNKNOWN"));
+}
+
+/*
* Get a zpool property value for 'prop' and return the value in
* a pre-allocated buffer.
*/
@@ -3605,7 +3633,7 @@ find_start_block(nvlist_t *config)
* stripped of any leading /dev path.
*/
int
-zpool_label_disk(libzfs_handle_t *hdl, zpool_handle_t *zhp, char *name)
+zpool_label_disk(libzfs_handle_t *hdl, zpool_handle_t *zhp, const char *name)
{
#ifdef sun
char path[MAXPATHLEN];
Date: Mon Jul 18 02:13:21 2011
New Revision: 224169
URL: http://svn.freebsd.org/changeset/base/224169
Log:
cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h:
cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c:
o Add zpool_pool_state_to_name() API to libzfs which converts a
pool_state_t into a user consumable string.
o While here, correct constness of make zpool_state_to_name()
and zpool_label_disk().
MFD after: 1 week
Modified:
head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h
head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c
Modified: head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
==============================================================================
--- head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c Mon Jul 18 01:09:43 2011 (r224168)
+++ head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c Mon Jul 18 02:13:21 2011 (r224169)
@@ -1052,7 +1052,7 @@ print_status_config(zpool_handle_t *zhp,
char *vname;
uint64_t notpresent;
spare_cbdata_t cb;
- char *state;
+ const char *state;
if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_CHILDREN,
&child, &children) != 0)
Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h
==============================================================================
--- head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h Mon Jul 18 01:09:43 2011 (r224168)
+++ head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h Mon Jul 18 02:13:21 2011 (r224169)
@@ -200,7 +200,8 @@ extern zpool_handle_t *zpool_open_canfai
extern void zpool_close(zpool_handle_t *);
extern const char *zpool_get_name(zpool_handle_t *);
extern int zpool_get_state(zpool_handle_t *);
-extern char *zpool_state_to_name(vdev_state_t, vdev_aux_t);
+extern const char *zpool_state_to_name(vdev_state_t, vdev_aux_t);
+extern const char *zpool_pool_state_to_name(pool_state_t);
extern void zpool_free_handles(libzfs_handle_t *);
/*
@@ -249,7 +250,7 @@ extern nvlist_t *zpool_find_vdev(zpool_h
boolean_t *, boolean_t *);
extern nvlist_t *zpool_find_vdev_by_physpath(zpool_handle_t *, const char *,
boolean_t *, boolean_t *, boolean_t *);
-extern int zpool_label_disk(libzfs_handle_t *, zpool_handle_t *, char *);
+extern int zpool_label_disk(libzfs_handle_t *, zpool_handle_t *, const char *);
/*
* Functions to manage pool properties
Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c
==============================================================================
--- head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c Mon Jul 18 01:09:43 2011 (r224168)
+++ head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c Mon Jul 18 02:13:21 2011 (r224169)
@@ -174,7 +174,7 @@ zpool_get_prop_int(zpool_handle_t *zhp,
/*
* Map VDEV STATE to printed strings.
*/
-char *
+const char *
zpool_state_to_name(vdev_state_t state, vdev_aux_t aux)
{
switch (state) {
@@ -202,6 +202,34 @@ zpool_state_to_name(vdev_state_t state,
}
/*
+ * Map POOL STATE to printed strings.
+ */
+const char *
+zpool_pool_state_to_name(pool_state_t state)
+{
+ switch (state) {
+ case POOL_STATE_ACTIVE:
+ return (gettext("ACTIVE"));
+ case POOL_STATE_EXPORTED:
+ return (gettext("EXPORTED"));
+ case POOL_STATE_DESTROYED:
+ return (gettext("DESTROYED"));
+ case POOL_STATE_SPARE:
+ return (gettext("SPARE"));
+ case POOL_STATE_L2CACHE:
+ return (gettext("L2CACHE"));
+ case POOL_STATE_UNINITIALIZED:
+ return (gettext("UNINITIALIZED"));
+ case POOL_STATE_UNAVAIL:
+ return (gettext("UNAVAIL"));
+ case POOL_STATE_POTENTIALLY_ACTIVE:
+ return (gettext("POTENTIALLY_ACTIVE"));
+ }
+
+ return (gettext("UNKNOWN"));
+}
+
+/*
* Get a zpool property value for 'prop' and return the value in
* a pre-allocated buffer.
*/
@@ -3605,7 +3633,7 @@ find_start_block(nvlist_t *config)
* stripped of any leading /dev path.
*/
int
-zpool_label_disk(libzfs_handle_t *hdl, zpool_handle_t *zhp, char *name)
+zpool_label_disk(libzfs_handle_t *hdl, zpool_handle_t *zhp, const char *name)
{
#ifdef sun
char path[MAXPATHLEN];