xref: /illumos-gate/usr/src/cmd/fm/schemes/sw/scheme.c (revision 6a634c9d)
1*f6e214c7SGavin Maltby /*
2*f6e214c7SGavin Maltby  * CDDL HEADER START
3*f6e214c7SGavin Maltby  *
4*f6e214c7SGavin Maltby  * The contents of this file are subject to the terms of the
5*f6e214c7SGavin Maltby  * Common Development and Distribution License (the "License").
6*f6e214c7SGavin Maltby  * You may not use this file except in compliance with the License.
7*f6e214c7SGavin Maltby  *
8*f6e214c7SGavin Maltby  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*f6e214c7SGavin Maltby  * or http://www.opensolaris.org/os/licensing.
10*f6e214c7SGavin Maltby  * See the License for the specific language governing permissions
11*f6e214c7SGavin Maltby  * and limitations under the License.
12*f6e214c7SGavin Maltby  *
13*f6e214c7SGavin Maltby  * When distributing Covered Code, include this CDDL HEADER in each
14*f6e214c7SGavin Maltby  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*f6e214c7SGavin Maltby  * If applicable, add the following below this CDDL HEADER, with the
16*f6e214c7SGavin Maltby  * fields enclosed by brackets "[]" replaced with your own identifying
17*f6e214c7SGavin Maltby  * information: Portions Copyright [yyyy] [name of copyright owner]
18*f6e214c7SGavin Maltby  *
19*f6e214c7SGavin Maltby  * CDDL HEADER END
20*f6e214c7SGavin Maltby  */
21*f6e214c7SGavin Maltby 
22*f6e214c7SGavin Maltby /*
23*f6e214c7SGavin Maltby  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24*f6e214c7SGavin Maltby  */
25*f6e214c7SGavin Maltby 
26*f6e214c7SGavin Maltby #include <fm/fmd_fmri.h>
27*f6e214c7SGavin Maltby #include <fm/libtopo.h>
28*f6e214c7SGavin Maltby #include <fm/topo_mod.h>
29*f6e214c7SGavin Maltby #include <string.h>
30*f6e214c7SGavin Maltby #include <sys/fm/protocol.h>
31*f6e214c7SGavin Maltby 
32*f6e214c7SGavin Maltby int
fmd_fmri_init(void)33*f6e214c7SGavin Maltby fmd_fmri_init(void)
34*f6e214c7SGavin Maltby {
35*f6e214c7SGavin Maltby 	return (0);
36*f6e214c7SGavin Maltby }
37*f6e214c7SGavin Maltby 
38*f6e214c7SGavin Maltby void
fmd_fmri_fini(void)39*f6e214c7SGavin Maltby fmd_fmri_fini(void)
40*f6e214c7SGavin Maltby {
41*f6e214c7SGavin Maltby }
42*f6e214c7SGavin Maltby 
43*f6e214c7SGavin Maltby ssize_t
fmd_fmri_nvl2str(nvlist_t * nvl,char * buf,size_t buflen)44*f6e214c7SGavin Maltby fmd_fmri_nvl2str(nvlist_t *nvl, char *buf, size_t buflen)
45*f6e214c7SGavin Maltby {
46*f6e214c7SGavin Maltby 	int err;
47*f6e214c7SGavin Maltby 	ssize_t len;
48*f6e214c7SGavin Maltby 	topo_hdl_t *thp;
49*f6e214c7SGavin Maltby 	char *str;
50*f6e214c7SGavin Maltby 
51*f6e214c7SGavin Maltby 	if ((thp = fmd_fmri_topo_hold(TOPO_VERSION)) == NULL)
52*f6e214c7SGavin Maltby 		return (fmd_fmri_set_errno(EINVAL));
53*f6e214c7SGavin Maltby 
54*f6e214c7SGavin Maltby 	if (topo_fmri_nvl2str(thp, nvl, &str, &err) != 0) {
55*f6e214c7SGavin Maltby 		fmd_fmri_topo_rele(thp);
56*f6e214c7SGavin Maltby 		return (fmd_fmri_set_errno(EINVAL));
57*f6e214c7SGavin Maltby 	}
58*f6e214c7SGavin Maltby 
59*f6e214c7SGavin Maltby 	if (buf != NULL)
60*f6e214c7SGavin Maltby 		len = snprintf(buf, buflen, "%s", str);
61*f6e214c7SGavin Maltby 	else
62*f6e214c7SGavin Maltby 		len = strlen(str);
63*f6e214c7SGavin Maltby 
64*f6e214c7SGavin Maltby 	topo_hdl_strfree(thp, str);
65*f6e214c7SGavin Maltby 	fmd_fmri_topo_rele(thp);
66*f6e214c7SGavin Maltby 
67*f6e214c7SGavin Maltby 	return (len);
68*f6e214c7SGavin Maltby }
69*f6e214c7SGavin Maltby 
70*f6e214c7SGavin Maltby /*ARGSUSED*/
71*f6e214c7SGavin Maltby int
fmd_fmri_present(nvlist_t * nvl)72*f6e214c7SGavin Maltby fmd_fmri_present(nvlist_t *nvl)
73*f6e214c7SGavin Maltby {
74*f6e214c7SGavin Maltby 	return (1);
75*f6e214c7SGavin Maltby }
76*f6e214c7SGavin Maltby 
77*f6e214c7SGavin Maltby /*ARGSUSED*/
78*f6e214c7SGavin Maltby int
fmd_fmri_replaced(nvlist_t * nvl)79*f6e214c7SGavin Maltby fmd_fmri_replaced(nvlist_t *nvl)
80*f6e214c7SGavin Maltby {
81*f6e214c7SGavin Maltby 	return (FMD_OBJ_STATE_UNKNOWN);
82*f6e214c7SGavin Maltby }
83*f6e214c7SGavin Maltby 
84*f6e214c7SGavin Maltby /*ARGSUSED*/
85*f6e214c7SGavin Maltby int
fmd_fmri_service_state(nvlist_t * nvl)86*f6e214c7SGavin Maltby fmd_fmri_service_state(nvlist_t *nvl)
87*f6e214c7SGavin Maltby {
88*f6e214c7SGavin Maltby 	return (FMD_SERVICE_STATE_UNKNOWN);
89*f6e214c7SGavin Maltby }
90*f6e214c7SGavin Maltby 
91*f6e214c7SGavin Maltby /*ARGSUSED*/
92*f6e214c7SGavin Maltby int
fmd_fmri_unusable(nvlist_t * nvl)93*f6e214c7SGavin Maltby fmd_fmri_unusable(nvlist_t *nvl)
94*f6e214c7SGavin Maltby {
95*f6e214c7SGavin Maltby 	return (0);
96*f6e214c7SGavin Maltby }
97