zfs.c revision ede7616dd3d88cda07ba148ab19e700804507747
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
d5b8f72dcc21ae549bc00501dd26eeb2b94bf2edStephen Hanson * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh * Use is subject to license terms.
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,
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,
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh (void) topo_method_register(mod, pnode, zfs_methods);
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh return (0);
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh/*ARGSUSED*/
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephhtypedef struct cbdata {
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh if (zpool_get_prop_int(zhp, ZPOOL_PROP_GUID, NULL) == cbp->cb_guid) {
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh return (1);
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh return (0);
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh const char *name;
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh (void) nvlist_lookup_uint64(nvl, FM_FMRI_ZFS_POOL, &pool_guid);
b7d3956b92a285d8dac2c7f5f7e28d2ef5347ef8stephh * Attempt to convert the pool guid to a name.
d5b8f72dcc21ae549bc00501dd26eeb2b94bf2edStephen Hanson if (g_zfs != NULL && zpool_iter(g_zfs, find_pool, &cb) == 1) {
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);