xref: /titanic_50/usr/src/cmd/fm/schemes/pkg/scheme.c (revision 60471b7bbfab236de7d8776aed871d919c5f81c3)
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 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #pragma ident	"%Z%%M%	%I%	%E% SMI"
27 
28 #include <fm/fmd_fmri.h>
29 #include <fm/libtopo.h>
30 #include <strings.h>
31 
32 ssize_t
33 fmd_fmri_nvl2str(nvlist_t *nvl, char *buf, size_t buflen)
34 {
35 	int err;
36 	ssize_t len;
37 	topo_hdl_t *thp;
38 	char *str;
39 
40 	if ((thp = fmd_fmri_topo_hold(TOPO_VERSION)) == NULL)
41 		return (fmd_fmri_set_errno(EINVAL));
42 
43 	if (topo_fmri_nvl2str(thp, nvl, &str, &err) != 0) {
44 		fmd_fmri_topo_rele(thp);
45 		return (fmd_fmri_set_errno(EINVAL));
46 	}
47 
48 	if (buf != NULL)
49 		len = snprintf(buf, buflen, "%s", str);
50 	else
51 		len = strlen(str);
52 
53 	topo_hdl_strfree(thp, str);
54 	fmd_fmri_topo_rele(thp);
55 
56 	return (len);
57 }
58 
59 /*
60  * fmd_fmri_present() is called by fmadm to determine if a faulty ASRU
61  * is still present in the system.  In general we don't expect to get
62  * ASRUs in this scheme, so it's unlikely this routine will get called.
63  * In case it does, though, we just return true by default, as we have no
64  * real way to look up the component in the system configuration.
65  */
66 /*ARGSUSED*/
67 int
68 fmd_fmri_present(nvlist_t *nvl)
69 {
70 	return (1);
71 }
72 
73 /*
74  * fmd_fmri_unusable() is called by fmadm to determine if a faulty ASRU
75  * is usable.  In general we don't expect to get ASRUs in this scheme,
76  * so it's unlikely this routine will get called.  In case it does,
77  * though, we just return false by default, as we have no real way to
78  * find the component or determine the component's usability.
79  */
80 /*ARGSUSED*/
81 int
82 fmd_fmri_unusable(nvlist_t *nvl)
83 {
84 	return (0);
85 }
86