10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7197Sstephh * Common Development and Distribution License (the "License"). 6*7197Sstephh * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*7197Sstephh * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 270Sstevel@tonic-gate 280Sstevel@tonic-gate #include <fm/fmd_fmri.h> 29*7197Sstephh #include <fm/libtopo.h> 30*7197Sstephh #include <strings.h> 310Sstevel@tonic-gate 320Sstevel@tonic-gate ssize_t 330Sstevel@tonic-gate fmd_fmri_nvl2str(nvlist_t *nvl, char *buf, size_t buflen) 340Sstevel@tonic-gate { 350Sstevel@tonic-gate int err; 36*7197Sstephh ssize_t len; 37*7197Sstephh topo_hdl_t *thp; 38*7197Sstephh char *str; 390Sstevel@tonic-gate 40*7197Sstephh if ((thp = fmd_fmri_topo_hold(TOPO_VERSION)) == NULL) 410Sstevel@tonic-gate return (fmd_fmri_set_errno(EINVAL)); 420Sstevel@tonic-gate 43*7197Sstephh if (topo_fmri_nvl2str(thp, nvl, &str, &err) != 0) { 44*7197Sstephh fmd_fmri_topo_rele(thp); 45*7197Sstephh return (fmd_fmri_set_errno(EINVAL)); 460Sstevel@tonic-gate } 470Sstevel@tonic-gate 48*7197Sstephh if (buf != NULL) 49*7197Sstephh len = snprintf(buf, buflen, "%s", str); 50*7197Sstephh else 51*7197Sstephh len = strlen(str); 520Sstevel@tonic-gate 53*7197Sstephh topo_hdl_strfree(thp, str); 54*7197Sstephh fmd_fmri_topo_rele(thp); 550Sstevel@tonic-gate 56*7197Sstephh return (len); 570Sstevel@tonic-gate } 580Sstevel@tonic-gate 590Sstevel@tonic-gate /* 600Sstevel@tonic-gate * fmd_fmri_present() is called by fmadm to determine if a faulty ASRU 610Sstevel@tonic-gate * is still present in the system. In general we don't expect to get 620Sstevel@tonic-gate * ASRUs in this scheme, so it's unlikely this routine will get called. 630Sstevel@tonic-gate * In case it does, though, we just return true by default, as we have no 640Sstevel@tonic-gate * real way to look up the component in the system configuration. 650Sstevel@tonic-gate */ 660Sstevel@tonic-gate /*ARGSUSED*/ 670Sstevel@tonic-gate int 680Sstevel@tonic-gate fmd_fmri_present(nvlist_t *nvl) 690Sstevel@tonic-gate { 700Sstevel@tonic-gate return (1); 710Sstevel@tonic-gate } 720Sstevel@tonic-gate 730Sstevel@tonic-gate /* 740Sstevel@tonic-gate * fmd_fmri_unusable() is called by fmadm to determine if a faulty ASRU 750Sstevel@tonic-gate * is usable. In general we don't expect to get ASRUs in this scheme, 760Sstevel@tonic-gate * so it's unlikely this routine will get called. In case it does, 770Sstevel@tonic-gate * though, we just return false by default, as we have no real way to 780Sstevel@tonic-gate * find the component or determine the component's usability. 790Sstevel@tonic-gate */ 800Sstevel@tonic-gate /*ARGSUSED*/ 810Sstevel@tonic-gate int 820Sstevel@tonic-gate fmd_fmri_unusable(nvlist_t *nvl) 830Sstevel@tonic-gate { 840Sstevel@tonic-gate return (0); 850Sstevel@tonic-gate } 86