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) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2012 Milan Jurik. All rights reserved.
25 * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
26 * Copyright (c) 2017, Joyent, Inc.
27 */
28
29 #include <alloca.h>
30 #include <dirent.h>
31 #include <devid.h>
32 #include <fm/libdiskstatus.h>
33 #include <inttypes.h>
34 #include <pthread.h>
35 #include <strings.h>
36 #include <string.h>
37 #include <unistd.h>
38 #include <sys/dkio.h>
39 #include <sys/fm/protocol.h>
40 #include <sys/libdevid.h>
41 #include <sys/scsi/scsi_types.h>
42 #include <sys/byteorder.h>
43 #include <pthread.h>
44 #include <signal.h>
45 #include <fcntl.h>
1000
1001 (void) pthread_mutex_unlock(&tp->set_lock);
1002 }
1003
1004 /*
1005 * Determine if the element is present.
1006 */
1007 /*ARGSUSED*/
1008 static int
1009 ses_present(topo_mod_t *mod, tnode_t *tn, topo_version_t version,
1010 nvlist_t *in, nvlist_t **out)
1011 {
1012 boolean_t present;
1013 ses_node_t *np;
1014 nvlist_t *props, *nvl;
1015 uint64_t status;
1016
1017 if ((np = ses_node_lock(mod, tn)) == NULL)
1018 return (-1);
1019
1020 verify((props = ses_node_props(np)) != NULL);
1021 verify(nvlist_lookup_uint64(props,
1022 SES_PROP_STATUS_CODE, &status) == 0);
1023
1024 ses_node_unlock(mod, tn);
1025
1026 present = (status != SES_ESC_NOT_INSTALLED);
1027
1028 if (topo_mod_nvalloc(mod, &nvl, NV_UNIQUE_NAME) != 0)
1029 return (topo_mod_seterrno(mod, EMOD_FMRI_NVL));
1030
1031 if (nvlist_add_uint32(nvl, TOPO_METH_PRESENT_RET,
1032 present) != 0) {
1033 nvlist_free(nvl);
1034 return (topo_mod_seterrno(mod, EMOD_FMRI_NVL));
1035 }
1036
1037 *out = nvl;
1038
1039 return (0);
1040 }
1041
1042 /*
|
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) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2012 Milan Jurik. All rights reserved.
25 * Copyright 2017 Nexenta Systems, Inc. All rights reserved.
26 * Copyright (c) 2017, Joyent, Inc.
27 */
28
29 #include <alloca.h>
30 #include <dirent.h>
31 #include <devid.h>
32 #include <fm/libdiskstatus.h>
33 #include <inttypes.h>
34 #include <pthread.h>
35 #include <strings.h>
36 #include <string.h>
37 #include <unistd.h>
38 #include <sys/dkio.h>
39 #include <sys/fm/protocol.h>
40 #include <sys/libdevid.h>
41 #include <sys/scsi/scsi_types.h>
42 #include <sys/byteorder.h>
43 #include <pthread.h>
44 #include <signal.h>
45 #include <fcntl.h>
1000
1001 (void) pthread_mutex_unlock(&tp->set_lock);
1002 }
1003
1004 /*
1005 * Determine if the element is present.
1006 */
1007 /*ARGSUSED*/
1008 static int
1009 ses_present(topo_mod_t *mod, tnode_t *tn, topo_version_t version,
1010 nvlist_t *in, nvlist_t **out)
1011 {
1012 boolean_t present;
1013 ses_node_t *np;
1014 nvlist_t *props, *nvl;
1015 uint64_t status;
1016
1017 if ((np = ses_node_lock(mod, tn)) == NULL)
1018 return (-1);
1019
1020 /*
1021 * If the SES properties are not there or
1022 * status cannot be determined, continue
1023 * and indicate status is unknown.
1024 */
1025 if (((props = ses_node_props(np)) == NULL) ||
1026 (nvlist_lookup_uint64(props,
1027 SES_PROP_STATUS_CODE, &status) != 0)) {
1028 status = SES_ESC_UNKNOWN;
1029 }
1030
1031 ses_node_unlock(mod, tn);
1032
1033 present = (status != SES_ESC_NOT_INSTALLED);
1034
1035 if (topo_mod_nvalloc(mod, &nvl, NV_UNIQUE_NAME) != 0)
1036 return (topo_mod_seterrno(mod, EMOD_FMRI_NVL));
1037
1038 if (nvlist_add_uint32(nvl, TOPO_METH_PRESENT_RET,
1039 present) != 0) {
1040 nvlist_free(nvl);
1041 return (topo_mod_seterrno(mod, EMOD_FMRI_NVL));
1042 }
1043
1044 *out = nvl;
1045
1046 return (0);
1047 }
1048
1049 /*
|