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
57197Sstephh * Common Development and Distribution License (the "License").
67197Sstephh * 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*11416SStephen.Hanson@Sun.COM * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
230Sstevel@tonic-gate * Use is subject to license terms.
240Sstevel@tonic-gate */
250Sstevel@tonic-gate
260Sstevel@tonic-gate #include <fm/fmd_fmri.h>
277197Sstephh #include <fm/libtopo.h>
287197Sstephh #include <strings.h>
290Sstevel@tonic-gate
300Sstevel@tonic-gate ssize_t
fmd_fmri_nvl2str(nvlist_t * nvl,char * buf,size_t buflen)310Sstevel@tonic-gate fmd_fmri_nvl2str(nvlist_t *nvl, char *buf, size_t buflen)
320Sstevel@tonic-gate {
330Sstevel@tonic-gate int err;
347197Sstephh ssize_t len;
357197Sstephh topo_hdl_t *thp;
367197Sstephh char *str;
370Sstevel@tonic-gate
387197Sstephh if ((thp = fmd_fmri_topo_hold(TOPO_VERSION)) == NULL)
390Sstevel@tonic-gate return (fmd_fmri_set_errno(EINVAL));
400Sstevel@tonic-gate
417197Sstephh if (topo_fmri_nvl2str(thp, nvl, &str, &err) != 0) {
427197Sstephh fmd_fmri_topo_rele(thp);
437197Sstephh return (fmd_fmri_set_errno(EINVAL));
440Sstevel@tonic-gate }
450Sstevel@tonic-gate
467197Sstephh if (buf != NULL)
477197Sstephh len = snprintf(buf, buflen, "%s", str);
487197Sstephh else
497197Sstephh len = strlen(str);
500Sstevel@tonic-gate
517197Sstephh topo_hdl_strfree(thp, str);
527197Sstephh fmd_fmri_topo_rele(thp);
530Sstevel@tonic-gate
547197Sstephh return (len);
550Sstevel@tonic-gate }
560Sstevel@tonic-gate
570Sstevel@tonic-gate /*
58*11416SStephen.Hanson@Sun.COM * fmd_fmri_present() is called by fmadm to determine if a faulty resource
59*11416SStephen.Hanson@Sun.COM * is still present in the system. We just return true by default, as we have no
600Sstevel@tonic-gate * real way to look up the component in the system configuration.
610Sstevel@tonic-gate */
620Sstevel@tonic-gate /*ARGSUSED*/
630Sstevel@tonic-gate int
fmd_fmri_present(nvlist_t * nvl)640Sstevel@tonic-gate fmd_fmri_present(nvlist_t *nvl)
650Sstevel@tonic-gate {
660Sstevel@tonic-gate return (1);
670Sstevel@tonic-gate }
680Sstevel@tonic-gate
69*11416SStephen.Hanson@Sun.COM /*ARGSUSED*/
70*11416SStephen.Hanson@Sun.COM int
fmd_fmri_replaced(nvlist_t * nvl)71*11416SStephen.Hanson@Sun.COM fmd_fmri_replaced(nvlist_t *nvl)
72*11416SStephen.Hanson@Sun.COM {
73*11416SStephen.Hanson@Sun.COM return (FMD_OBJ_STATE_UNKNOWN);
74*11416SStephen.Hanson@Sun.COM }
75*11416SStephen.Hanson@Sun.COM
760Sstevel@tonic-gate /*
770Sstevel@tonic-gate * fmd_fmri_unusable() is called by fmadm to determine if a faulty ASRU
780Sstevel@tonic-gate * is usable. In general we don't expect to get ASRUs in this scheme,
790Sstevel@tonic-gate * so it's unlikely this routine will get called. In case it does,
800Sstevel@tonic-gate * though, we just return false by default, as we have no real way to
810Sstevel@tonic-gate * find the component or determine the component's usability.
820Sstevel@tonic-gate */
830Sstevel@tonic-gate /*ARGSUSED*/
840Sstevel@tonic-gate int
fmd_fmri_unusable(nvlist_t * nvl)850Sstevel@tonic-gate fmd_fmri_unusable(nvlist_t *nvl)
860Sstevel@tonic-gate {
870Sstevel@tonic-gate return (0);
880Sstevel@tonic-gate }
89