xref: /illumos-gate/usr/src/cmd/fm/schemes/sw/scheme.c (revision d0698e0d179f97729cacdbc2f13446a6b0a3f22a)
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 /*
23  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24  */
25 
26 #include <fm/fmd_fmri.h>
27 #include <fm/libtopo.h>
28 #include <fm/topo_mod.h>
29 #include <string.h>
30 #include <sys/fm/protocol.h>
31 
32 int
33 fmd_fmri_init(void)
34 {
35 	return (0);
36 }
37 
38 void
39 fmd_fmri_fini(void)
40 {
41 }
42 
43 ssize_t
44 fmd_fmri_nvl2str(nvlist_t *nvl, char *buf, size_t buflen)
45 {
46 	int err;
47 	ssize_t len;
48 	topo_hdl_t *thp;
49 	char *str;
50 
51 	if ((thp = fmd_fmri_topo_hold(TOPO_VERSION)) == NULL)
52 		return (fmd_fmri_set_errno(EINVAL));
53 
54 	if (topo_fmri_nvl2str(thp, nvl, &str, &err) != 0) {
55 		fmd_fmri_topo_rele(thp);
56 		return (fmd_fmri_set_errno(EINVAL));
57 	}
58 
59 	if (buf != NULL)
60 		len = snprintf(buf, buflen, "%s", str);
61 	else
62 		len = strlen(str);
63 
64 	topo_hdl_strfree(thp, str);
65 	fmd_fmri_topo_rele(thp);
66 
67 	return (len);
68 }
69 
70 /*ARGSUSED*/
71 int
72 fmd_fmri_present(nvlist_t *nvl)
73 {
74 	return (1);
75 }
76 
77 /*ARGSUSED*/
78 int
79 fmd_fmri_replaced(nvlist_t *nvl)
80 {
81 	return (FMD_OBJ_STATE_UNKNOWN);
82 }
83 
84 /*ARGSUSED*/
85 int
86 fmd_fmri_service_state(nvlist_t *nvl)
87 {
88 	return (FMD_SERVICE_STATE_UNKNOWN);
89 }
90 
91 /*ARGSUSED*/
92 int
93 fmd_fmri_unusable(nvlist_t *nvl)
94 {
95 	return (0);
96 }
97