b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh * CDDL HEADER START
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh * The contents of this file are subject to the terms of the
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh * Common Development and Distribution License (the "License").
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh * You may not use this file except in compliance with the License.
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh * See the License for the specific language governing permissions
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh * and limitations under the License.
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh * When distributing Covered Code, include this CDDL HEADER in each
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh * If applicable, add the following below this CDDL HEADER, with the
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh * fields enclosed by brackets "[]" replaced with your own identifying
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh * information: Portions Copyright [yyyy] [name of copyright owner]
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh * CDDL HEADER END
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
2227b8ad8ebd0984a34b696ce07145248700852bAlek Pinchuk * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephhstatic int zfs_enum(topo_mod_t *, tnode_t *, const char *, topo_instance_t,
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh topo_instance_t, void *, void *);
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephhstatic int zfs_fmri_nvl2str(topo_mod_t *, tnode_t *, topo_version_t,
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh { TOPO_METH_NVL2STR, TOPO_METH_NVL2STR_DESC, TOPO_METH_NVL2STR_VERSION,
2227b8ad8ebd0984a34b696ce07145248700852bAlek Pinchukstatic pthread_mutex_t g_lock = PTHREAD_MUTEX_INITIALIZER;
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh * Turn on module debugging output
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh if (topo_mod_register(mod, &zfs_info, TOPO_VERSION) != 0) {
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh return (0);
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh/*ARGSUSED*/
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephhzfs_enum(topo_mod_t *mod, tnode_t *pnode, const char *name, topo_instance_t min,
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * Methods are registered, but there is no enumeration. Should
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * enumeration be added be sure to cater for global vs non-global
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh (void) topo_method_register(mod, pnode, zfs_methods);
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh return (0);
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh/*ARGSUSED*/
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh if (zpool_get_prop_int(zhp, ZPOOL_PROP_GUID, NULL) == cbp->cb_guid) {
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh return (1);
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh return (0);
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh (void) nvlist_lookup_uint64(nvl, FM_FMRI_ZFS_POOL, &pool_guid);
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh * Attempt to convert the pool guid to a name.
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh (void) snprintf(guidbuf, sizeof (guidbuf), "%llx", pool_guid);
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh if (nvlist_lookup_uint64(nvl, FM_FMRI_ZFS_VDEV, &vdev_guid) == 0)
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh len = snprintf(buf, buflen, "%s://pool=%s/vdev=%llx",
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh/*ARGSUSED*/
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephhzfs_fmri_nvl2str(topo_mod_t *mod, tnode_t *node, topo_version_t version,
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh if (topo_mod_nvalloc(mod, &fmristr, NV_UNIQUE_NAME) != 0) {
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh if (nvlist_add_string(fmristr, "fmri-string", name) != 0) {
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh return (0);