xref: /titanic_50/usr/src/cmd/fm/schemes/pkg/scheme.c (revision 8c4f9701439555b41fbfe7848508f53b52166007)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #include <fm/fmd_fmri.h>
27 #include <fm/libtopo.h>
28 #include <strings.h>
29 
30 ssize_t
31 fmd_fmri_nvl2str(nvlist_t *nvl, char *buf, size_t buflen)
32 {
33 	int err;
34 	ssize_t len;
35 	topo_hdl_t *thp;
36 	char *str;
37 
38 	if ((thp = fmd_fmri_topo_hold(TOPO_VERSION)) == NULL)
39 		return (fmd_fmri_set_errno(EINVAL));
40 
41 	if (topo_fmri_nvl2str(thp, nvl, &str, &err) != 0) {
42 		fmd_fmri_topo_rele(thp);
43 		return (fmd_fmri_set_errno(EINVAL));
44 	}
45 
46 	if (buf != NULL)
47 		len = snprintf(buf, buflen, "%s", str);
48 	else
49 		len = strlen(str);
50 
51 	topo_hdl_strfree(thp, str);
52 	fmd_fmri_topo_rele(thp);
53 
54 	return (len);
55 }
56 
57 /*
58  * fmd_fmri_present() is called by fmadm to determine if a faulty resource
59  * is still present in the system. We just return true by default, as we have no
60  * real way to look up the component in the system configuration.
61  */
62 /*ARGSUSED*/
63 int
64 fmd_fmri_present(nvlist_t *nvl)
65 {
66 	return (1);
67 }
68 
69 /*ARGSUSED*/
70 int
71 fmd_fmri_replaced(nvlist_t *nvl)
72 {
73 	return (FMD_OBJ_STATE_UNKNOWN);
74 }
75 
76 /*
77  * fmd_fmri_unusable() is called by fmadm to determine if a faulty ASRU
78  * is usable.  In general we don't expect to get ASRUs in this scheme,
79  * so it's unlikely this routine will get called.  In case it does,
80  * though, we just return false by default, as we have no real way to
81  * find the component or determine the component's usability.
82  */
83 /*ARGSUSED*/
84 int
85 fmd_fmri_unusable(nvlist_t *nvl)
86 {
87 	return (0);
88 }
89