Mercurial > illumos > illumos-gate
annotate usr/src/lib/fm/topo/libtopo/common/dev.c @ 12979:ab9ae749152f
PSARC/2009/617 Software Events Notification Parameters CLI
PSARC/2009/618 snmp-notify: SNMP Notification Daemon for Software Events
PSARC/2009/619 smtp-notify: Email Notification Daemon for Software Events
PSARC/2010/225 fmd for non-global Solaris zones
PSARC/2010/226 Solaris Instance UUID
PSARC/2010/227 nvlist_nvflag(3NVPAIR)
PSARC/2010/228 libfmevent additions
PSARC/2010/257 sysevent_evc_setpropnvl and sysevent_evc_getpropnvl
PSARC/2010/265 FMRI and FMA Event Stabilty, 'ireport' category 1 event class, and the 'sw' FMRI scheme
PSARC/2010/278 FMA/SMF integration: instance state transitions
PSARC/2010/279 Modelling panics within FMA
PSARC/2010/290 logadm.conf upgrade
6392476 fmdump needs to pretty-print
6393375 userland ereport/ireport event generation interfaces
6445732 Add email notification agent for FMA and software events
6804168 RFE: Allow an efficient means to monitor SMF services status changes
6866661 scf_values_destroy(3SCF) will segfault if is passed NULL
6884709 Add snmp notification agent for FMA and software events
6884712 Add private interface to tap into libfmd_msg macro expansion capabilities
6897919 fmd to run in a non-global zone
6897937 fmd use of non-private doors is not safe
6900081 add a UUID to Solaris kernel image for use in crashdump identification
6914884 model panic events as a defect diagnosis in FMA
6944862 fmd_case_open_uuid, fmd_case_uuisresolved, fmd_nvl_create_defect
6944866 log legacy sysevents in fmd
6944867 enumerate svc scheme in topo
6944868 software-diagnosis and software-response fmd modules
6944870 model SMF maintenance state as a defect diagnosis in FMA
6944876 savecore runs in foreground for systems with zfs root and dedicated dump
6965796 Implement notification parameters for SMF state transitions and FMA events
6968287 SUN-FM-MIB.mib needs to be updated to reflect Oracle information
6972331 logadm.conf upgrade PSARC/2010/290
author | Gavin Maltby <gavin.maltby@oracle.com> |
---|---|
date | Fri, 30 Jul 2010 17:04:17 +1000 |
parents | 0e5eaf4bf546 |
children |
rev | line source |
---|---|
1541
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
1 /* |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
2 * CDDL HEADER START |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
3 * |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
4 * The contents of this file are subject to the terms of the |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
5 * Common Development and Distribution License (the "License"). |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
6 * You may not use this file except in compliance with the License. |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
7 * |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
9 * or http://www.opensolaris.org/os/licensing. |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
10 * See the License for the specific language governing permissions |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
11 * and limitations under the License. |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
12 * |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
13 * When distributing Covered Code, include this CDDL HEADER in each |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
15 * If applicable, add the following below this CDDL HEADER, with the |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
16 * fields enclosed by brackets "[]" replaced with your own identifying |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
17 * information: Portions Copyright [yyyy] [name of copyright owner] |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
18 * |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
19 * CDDL HEADER END |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
20 */ |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
21 |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
22 /* |
12213
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
23 * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. |
1541
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
24 */ |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
25 |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
26 #include <limits.h> |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
27 #include <strings.h> |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
28 #include <string.h> |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
29 #include <unistd.h> |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
30 #include <stdio.h> |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
31 #include <alloca.h> |
4198
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
32 #include <devid.h> |
6135
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
33 #include <sys/stat.h> |
1541
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
34 #include <libnvpair.h> |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
35 #include <fm/topo_mod.h> |
7275 | 36 #include <fm/fmd_fmri.h> |
1541
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
37 #include <sys/fm/protocol.h> |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
38 |
3062 | 39 #include <topo_method.h> |
1541
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
40 #include <topo_subr.h> |
3062 | 41 #include <dev.h> |
1541
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
42 |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
43 static int dev_enum(topo_mod_t *, tnode_t *, const char *, topo_instance_t, |
3062 | 44 topo_instance_t, void *, void *); |
1541
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
45 static void dev_release(topo_mod_t *, tnode_t *); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
46 static int dev_fmri_nvl2str(topo_mod_t *, tnode_t *, topo_version_t, |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
47 nvlist_t *, nvlist_t **); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
48 static int dev_fmri_str2nvl(topo_mod_t *, tnode_t *, topo_version_t, |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
49 nvlist_t *, nvlist_t **); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
50 static int dev_fmri_create_meth(topo_mod_t *, tnode_t *, topo_version_t, |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
51 nvlist_t *, nvlist_t **); |
4198
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
52 static int dev_fmri_present(topo_mod_t *, tnode_t *, topo_version_t, |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
53 nvlist_t *, nvlist_t **); |
7275 | 54 static int dev_fmri_replaced(topo_mod_t *, tnode_t *, topo_version_t, |
55 nvlist_t *, nvlist_t **); | |
4198
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
56 static int dev_fmri_unusable(topo_mod_t *, tnode_t *, topo_version_t, |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
57 nvlist_t *, nvlist_t **); |
7275 | 58 static int dev_fmri_service_state(topo_mod_t *, tnode_t *, topo_version_t, |
59 nvlist_t *, nvlist_t **); | |
1541
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
60 |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
61 static const topo_method_t dev_methods[] = { |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
62 { TOPO_METH_NVL2STR, TOPO_METH_NVL2STR_DESC, TOPO_METH_NVL2STR_VERSION, |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
63 TOPO_STABILITY_INTERNAL, dev_fmri_nvl2str }, |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
64 { TOPO_METH_STR2NVL, TOPO_METH_STR2NVL_DESC, TOPO_METH_STR2NVL_VERSION, |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
65 TOPO_STABILITY_INTERNAL, dev_fmri_str2nvl }, |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
66 { TOPO_METH_FMRI, TOPO_METH_FMRI_DESC, TOPO_METH_FMRI_VERSION, |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
67 TOPO_STABILITY_INTERNAL, dev_fmri_create_meth }, |
4198
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
68 { TOPO_METH_PRESENT, TOPO_METH_PRESENT_DESC, TOPO_METH_PRESENT_VERSION, |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
69 TOPO_STABILITY_INTERNAL, dev_fmri_present }, |
7275 | 70 { TOPO_METH_REPLACED, TOPO_METH_REPLACED_DESC, |
71 TOPO_METH_REPLACED_VERSION, TOPO_STABILITY_INTERNAL, | |
72 dev_fmri_replaced }, | |
4198
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
73 { TOPO_METH_UNUSABLE, TOPO_METH_UNUSABLE_DESC, |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
74 TOPO_METH_UNUSABLE_VERSION, TOPO_STABILITY_INTERNAL, |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
75 dev_fmri_unusable }, |
7275 | 76 { TOPO_METH_SERVICE_STATE, TOPO_METH_SERVICE_STATE_DESC, |
77 TOPO_METH_SERVICE_STATE_VERSION, TOPO_STABILITY_INTERNAL, | |
78 dev_fmri_service_state }, | |
1541
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
79 { NULL } |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
80 }; |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
81 |
3062 | 82 static const topo_modops_t dev_ops = |
83 { dev_enum, dev_release }; | |
1541
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
84 static const topo_modinfo_t dev_info = |
3062 | 85 { "dev", FM_FMRI_SCHEME_DEV, DEV_VERSION, &dev_ops }; |
1541
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
86 |
3062 | 87 int |
88 dev_init(topo_mod_t *mod, topo_version_t version) | |
1541
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
89 { |
3062 | 90 if (getenv("TOPOHCDEBUG")) |
91 topo_mod_setdebug(mod); | |
1541
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
92 topo_mod_dprintf(mod, "initializing dev builtin\n"); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
93 |
3062 | 94 if (version != DEV_VERSION) |
95 return (topo_mod_seterrno(mod, EMOD_VER_NEW)); | |
96 | |
97 if (topo_mod_register(mod, &dev_info, TOPO_VERSION) != 0) { | |
1541
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
98 topo_mod_dprintf(mod, "failed to register dev_info: " |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
99 "%s\n", topo_mod_errmsg(mod)); |
3062 | 100 return (-1); |
1541
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
101 } |
3062 | 102 |
103 return (0); | |
1541
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
104 } |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
105 |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
106 void |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
107 dev_fini(topo_mod_t *mod) |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
108 { |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
109 topo_mod_unregister(mod); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
110 } |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
111 |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
112 /*ARGSUSED*/ |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
113 static int |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
114 dev_enum(topo_mod_t *mod, tnode_t *pnode, const char *name, |
3062 | 115 topo_instance_t min, topo_instance_t max, void *notused1, void *notused2) |
1541
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
116 { |
12979
ab9ae749152f
PSARC/2009/617 Software Events Notification Parameters CLI
Gavin Maltby <gavin.maltby@oracle.com>
parents:
12618
diff
changeset
|
117 /* |
ab9ae749152f
PSARC/2009/617 Software Events Notification Parameters CLI
Gavin Maltby <gavin.maltby@oracle.com>
parents:
12618
diff
changeset
|
118 * Methods are registered, but there is no enumeration. Should |
ab9ae749152f
PSARC/2009/617 Software Events Notification Parameters CLI
Gavin Maltby <gavin.maltby@oracle.com>
parents:
12618
diff
changeset
|
119 * enumeration be added be sure to cater for global vs non-global |
ab9ae749152f
PSARC/2009/617 Software Events Notification Parameters CLI
Gavin Maltby <gavin.maltby@oracle.com>
parents:
12618
diff
changeset
|
120 * zones. |
ab9ae749152f
PSARC/2009/617 Software Events Notification Parameters CLI
Gavin Maltby <gavin.maltby@oracle.com>
parents:
12618
diff
changeset
|
121 */ |
1541
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
122 (void) topo_method_register(mod, pnode, dev_methods); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
123 return (0); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
124 } |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
125 |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
126 static void |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
127 dev_release(topo_mod_t *mod, tnode_t *node) |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
128 { |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
129 topo_method_unregister_all(mod, node); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
130 } |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
131 |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
132 static ssize_t |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
133 fmri_nvl2str(nvlist_t *nvl, char *buf, size_t buflen) |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
134 { |
12213
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
135 char *devid = NULL, *tpl0id = NULL; |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
136 char *devpath = NULL; |
1541
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
137 ssize_t size = 0; |
12213
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
138 uint8_t version; |
1541
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
139 int err; |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
140 |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
141 if (nvlist_lookup_uint8(nvl, FM_VERSION, &version) != 0 || |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
142 version > FM_DEV_SCHEME_VERSION) |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
143 return (-1); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
144 |
12213
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
145 /* Get devid, if present */ |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
146 err = nvlist_lookup_string(nvl, FM_FMRI_DEV_ID, &devid); |
1541
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
147 if (err != 0 && err != ENOENT) |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
148 return (-1); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
149 |
12213
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
150 /* Get target-port-l0id, if present */ |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
151 err = nvlist_lookup_string(nvl, FM_FMRI_DEV_TGTPTLUN0, &tpl0id); |
1541
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
152 if (err != 0 && err != ENOENT) |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
153 return (-1); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
154 |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
155 /* There must be a device path present */ |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
156 err = nvlist_lookup_string(nvl, FM_FMRI_DEV_PATH, &devpath); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
157 if (err != 0 || devpath == NULL) |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
158 return (-1); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
159 |
12213
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
160 /* |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
161 * dev:/// |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
162 * |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
163 * The dev scheme does not render fmri authority information |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
164 * in the string form of an fmri. It is meaningless to |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
165 * transmit a dev scheme fmri outside of the immediate fault |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
166 * manager. |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
167 */ |
1541
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
168 topo_fmristr_build(&size, |
12213
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
169 buf, buflen, FM_FMRI_SCHEME_DEV, NULL, ":///"); |
1541
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
170 |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
171 /* device-id part, topo_fmristr_build does nothing if devid is NULL */ |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
172 topo_fmristr_build(&size, |
12213
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
173 buf, buflen, devid, ":" FM_FMRI_DEV_ID "=", NULL); |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
174 |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
175 /* target-port-l0id part */ |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
176 topo_fmristr_build(&size, |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
177 buf, buflen, tpl0id, ":" FM_FMRI_DEV_TGTPTLUN0 "=", NULL); |
1541
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
178 |
12213
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
179 /* |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
180 * device-path part; the devpath should always start with a / |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
181 * so you'd think we don't need to add a further / prefix here; |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
182 * however past implementation has always added the / if |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
183 * there is a devid component so we continue to do that |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
184 * so strings match exactly as before. So we can have: |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
185 * |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
186 * dev:////pci@0,0/... |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
187 * dev:///<devid-and-tpl0>//pci@0,0/... |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
188 * |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
189 * where <devid-and-tpl0> = |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
190 * [:devid=<devid>][:target-port-l0id=<tpl0>] |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
191 */ |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
192 topo_fmristr_build(&size, buf, buflen, devpath, |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
193 devid || tpl0id ? "/" : NULL, NULL); |
1541
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
194 |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
195 return (size); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
196 } |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
197 |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
198 /*ARGSUSED*/ |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
199 static int |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
200 dev_fmri_nvl2str(topo_mod_t *mod, tnode_t *node, topo_version_t version, |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
201 nvlist_t *nvl, nvlist_t **out) |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
202 { |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
203 ssize_t len; |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
204 char *name = NULL; |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
205 nvlist_t *fmristr; |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
206 |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
207 if (version > TOPO_METH_NVL2STR_VERSION) |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
208 return (topo_mod_seterrno(mod, EMOD_VER_NEW)); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
209 |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
210 if ((len = fmri_nvl2str(nvl, NULL, 0)) == 0 || |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
211 (name = topo_mod_alloc(mod, len + 1)) == NULL || |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
212 fmri_nvl2str(nvl, name, len + 1) == 0) { |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
213 if (name != NULL) |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
214 topo_mod_free(mod, name, len + 1); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
215 return (topo_mod_seterrno(mod, EMOD_FMRI_NVL)); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
216 } |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
217 |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
218 if (topo_mod_nvalloc(mod, &fmristr, NV_UNIQUE_NAME) != 0) |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
219 return (topo_mod_seterrno(mod, EMOD_FMRI_NVL)); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
220 if (nvlist_add_string(fmristr, "fmri-string", name) != 0) { |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
221 topo_mod_free(mod, name, len + 1); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
222 nvlist_free(fmristr); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
223 return (topo_mod_seterrno(mod, EMOD_FMRI_NVL)); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
224 } |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
225 topo_mod_free(mod, name, len + 1); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
226 *out = fmristr; |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
227 |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
228 return (0); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
229 } |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
230 |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
231 /*ARGSUSED*/ |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
232 static int |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
233 dev_fmri_str2nvl(topo_mod_t *mod, tnode_t *node, topo_version_t version, |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
234 nvlist_t *in, nvlist_t **out) |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
235 { |
12213
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
236 char *cur, *devid = NULL, *tpl0id = NULL; |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
237 char *str, *strcp; |
1541
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
238 nvlist_t *fmri; |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
239 char *devpath; |
12213
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
240 size_t len; |
1541
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
241 int err; |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
242 |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
243 if (version > TOPO_METH_STR2NVL_VERSION) |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
244 return (topo_mod_seterrno(mod, EMOD_VER_NEW)); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
245 |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
246 if (nvlist_lookup_string(in, "fmri-string", &str) != 0) |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
247 return (topo_mod_seterrno(mod, EMOD_FMRI_NVL)); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
248 |
12213
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
249 len = strlen(str); |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
250 |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
251 /* |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
252 * We're expecting a string version of a dev scheme FMRI, and |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
253 * no fmri authority information. |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
254 * |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
255 * The shortest legal string would be "dev:////" (len 8) for a string |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
256 * with no FMRI auth info, no devid or target-port-l0id and |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
257 * an empty devpath string. |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
258 */ |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
259 if (len < 8 || strncmp(str, "dev:///", 7) != 0) |
1541
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
260 return (topo_mod_seterrno(mod, EMOD_FMRI_MALFORM)); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
261 |
12213
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
262 strcp = alloca(len + 1); |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
263 (void) memcpy(strcp, str, len); |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
264 strcp[len] = '\0'; |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
265 cur = strcp + 7; /* already parsed "dev:///" */ |
1541
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
266 |
12213
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
267 /* |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
268 * If the first character after the "/" that terminates the (empty) |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
269 * fmri authority is a colon then we have devid and/or target-port-l0id |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
270 * info. They could be in either order. |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
271 * |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
272 * If not a colon then it must be the / that begins the devpath. |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
273 */ |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
274 if (*cur == ':') { |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
275 char *eos, *part[2]; |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
276 int i; |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
277 /* |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
278 * Look ahead to the "/" that starts the devpath. If not |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
279 * found or if straight after the : then we're busted. |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
280 */ |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
281 eos = devpath = strchr(cur, '/'); |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
282 if (devpath == NULL || devpath == cur + 1) |
1541
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
283 return (topo_mod_seterrno(mod, EMOD_FMRI_MALFORM)); |
12213
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
284 |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
285 part[0] = ++cur; |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
286 |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
287 /* |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
288 * Replace the initial "/" of the devpath with a NUL |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
289 * to terminate the string before it. We'll undo this |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
290 * before rendering devpath. |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
291 */ |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
292 *eos = '\0'; |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
293 |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
294 /* |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
295 * We should now have a NUL-terminated string matching |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
296 * foo=<pat1>[:bar=<pat2>] (we stepped over the initial :) |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
297 * Look for a second colon; if found there must be space |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
298 * after it for the additional component, but no more colons. |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
299 */ |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
300 if ((part[1] = strchr(cur, ':')) != NULL) { |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
301 if (part[1] + 1 == eos || |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
302 strchr(part[1] + 1, ':') != NULL) |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
303 return (topo_mod_seterrno(mod, |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
304 EMOD_FMRI_MALFORM)); |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
305 *part[1] = '\0'; /* terminate part[0] */ |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
306 part[1]++; |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
307 } |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
308 |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
309 for (i = 0; i < 2; i++) { |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
310 char *eq; |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
311 |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
312 if (!part[i]) |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
313 continue; |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
314 |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
315 if ((eq = strchr(part[i], '=')) == NULL || |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
316 *(eq + 1) == '\0') |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
317 return (topo_mod_seterrno(mod, |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
318 EMOD_FMRI_MALFORM)); |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
319 |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
320 *eq = '\0'; |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
321 if (strcmp(part[i], FM_FMRI_DEV_ID) == 0) |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
322 devid = eq + 1; |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
323 else if (strcmp(part[i], FM_FMRI_DEV_TGTPTLUN0) == 0) |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
324 tpl0id = eq + 1; |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
325 else |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
326 return (topo_mod_seterrno(mod, |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
327 EMOD_FMRI_MALFORM)); |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
328 } |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
329 |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
330 if (devid == NULL && tpl0id == NULL) |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
331 return (topo_mod_seterrno(mod, EMOD_FMRI_MALFORM)); |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
332 |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
333 cur = devpath; /* initial slash is NULled */ |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
334 } else if (*cur != '/') { |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
335 /* the device-path should start with a slash */ |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
336 return (topo_mod_seterrno(mod, EMOD_FMRI_MALFORM)); |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
337 } else { |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
338 devpath = cur; |
1541
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
339 } |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
340 |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
341 if (topo_mod_nvalloc(mod, &fmri, NV_UNIQUE_NAME) != 0) |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
342 return (topo_mod_seterrno(mod, EMOD_FMRI_NVL)); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
343 |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
344 err = nvlist_add_uint8(fmri, FM_VERSION, FM_DEV_SCHEME_VERSION); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
345 err |= nvlist_add_string(fmri, FM_FMRI_SCHEME, FM_FMRI_SCHEME_DEV); |
12213
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
346 |
1541
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
347 if (devid != NULL) |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
348 err |= nvlist_add_string(fmri, FM_FMRI_DEV_ID, devid); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
349 |
12213
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
350 if (tpl0id != NULL) |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
351 err |= nvlist_add_string(fmri, FM_FMRI_DEV_TGTPTLUN0, tpl0id); |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
352 |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
353 if (devid != NULL || tpl0id != NULL) |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
354 *devpath = '/'; /* we NULed this earlier; put it back */ |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
355 |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
356 /* step over repeated initial / in the devpath */ |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
357 while (*(devpath + 1) == '/') |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
358 devpath++; |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
359 |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
360 err |= nvlist_add_string(fmri, FM_FMRI_DEV_PATH, devpath); |
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
361 |
1541
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
362 if (err != 0) { |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
363 nvlist_free(fmri); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
364 return (topo_mod_seterrno(mod, EMOD_FMRI_NVL)); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
365 } |
12213
f49a344d4308
6935519 raise telemetry for failed scsa-initiated enumeration commands
Gavin Maltby <Gavin.Maltby@Sun.COM>
parents:
10462
diff
changeset
|
366 |
1541
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
367 *out = fmri; |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
368 |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
369 return (0); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
370 } |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
371 |
4198
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
372 /*ARGSUSED*/ |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
373 static int |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
374 dev_fmri_present(topo_mod_t *mod, tnode_t *node, topo_version_t version, |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
375 nvlist_t *in, nvlist_t **out) |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
376 { |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
377 uint8_t fmversion; |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
378 char *devpath = NULL; |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
379 uint32_t present; |
6135
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
380 char *devid = NULL, *path; |
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
381 ddi_devid_t id; |
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
382 ddi_devid_t matchid; |
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
383 di_node_t dnode; |
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
384 struct stat sb; |
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
385 int len; |
4198
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
386 |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
387 if (version > TOPO_METH_PRESENT_VERSION) |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
388 return (topo_mod_seterrno(mod, EMOD_VER_NEW)); |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
389 |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
390 if (nvlist_lookup_uint8(in, FM_VERSION, &fmversion) != 0 || |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
391 fmversion > FM_DEV_SCHEME_VERSION || |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
392 nvlist_lookup_string(in, FM_FMRI_DEV_PATH, &devpath) != 0) |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
393 return (topo_mod_seterrno(mod, EMOD_FMRI_MALFORM)); |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
394 |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
395 (void) nvlist_lookup_string(in, FM_FMRI_DEV_ID, &devid); |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
396 |
6135
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
397 if (devpath == NULL || strlen(devpath) == 0) |
4198
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
398 return (topo_mod_seterrno(mod, EMOD_FMRI_MALFORM)); |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
399 |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
400 /* |
6135
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
401 * stat() the device node in devfs. This will tell us if the device is |
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
402 * present or not. Don't stat the minor, just the whole device. |
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
403 * If the device is present and there is a devid, it must also match. |
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
404 * so di_init that one node. No need for DINFOFORCE. |
4198
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
405 */ |
7275 | 406 len = strlen(devpath) + strlen("/devices") + 1; |
6135
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
407 path = topo_mod_alloc(mod, len); |
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
408 (void) snprintf(path, len, "/devices%s", devpath); |
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
409 if (devid == NULL) { |
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
410 if (stat(path, &sb) != -1) |
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
411 present = 1; |
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
412 else if ((dnode = di_init("/", DINFOCACHE)) == DI_NODE_NIL) |
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
413 present = 0; |
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
414 else { |
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
415 if (di_lookup_node(dnode, devpath) == DI_NODE_NIL) |
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
416 present = 0; |
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
417 else |
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
418 present = 1; |
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
419 di_fini(dnode); |
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
420 } |
4198
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
421 } else { |
6135
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
422 if (stat(path, &sb) == -1) |
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
423 present = 0; |
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
424 else if ((dnode = di_init(devpath, DINFOCPYONE)) == DI_NODE_NIL) |
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
425 present = 0; |
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
426 else { |
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
427 if ((id = di_devid(dnode)) == NULL || |
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
428 devid_str_decode(devid, &matchid, NULL) != 0) |
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
429 present = 0; |
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
430 else { |
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
431 if (devid_compare(id, matchid) != 0) |
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
432 present = 0; |
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
433 else |
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
434 present = 1; |
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
435 devid_free(matchid); |
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
436 } |
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
437 di_fini(dnode); |
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
438 } |
4198
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
439 } |
6135
c403f3c9b1a7
6644768 fmadm faulty can be very slow if there are hbas in the suspect list
stephh
parents:
4845
diff
changeset
|
440 topo_mod_free(mod, path, len); |
4198
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
441 |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
442 if (topo_mod_nvalloc(mod, out, NV_UNIQUE_NAME) != 0) |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
443 return (topo_mod_seterrno(mod, EMOD_NVL_INVAL)); |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
444 if (nvlist_add_uint32(*out, TOPO_METH_PRESENT_RET, present) != 0) { |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
445 nvlist_free(*out); |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
446 return (topo_mod_seterrno(mod, EMOD_NVL_INVAL)); |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
447 } |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
448 |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
449 return (0); |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
450 } |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
451 |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
452 /*ARGSUSED*/ |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
453 static int |
7275 | 454 dev_fmri_replaced(topo_mod_t *mod, tnode_t *node, topo_version_t version, |
455 nvlist_t *in, nvlist_t **out) | |
456 { | |
457 uint8_t fmversion; | |
458 char *devpath = NULL; | |
459 uint32_t rval; | |
460 char *devid = NULL, *path; | |
461 ddi_devid_t id; | |
462 ddi_devid_t matchid; | |
463 di_node_t dnode; | |
464 struct stat sb; | |
465 int len; | |
466 | |
467 if (version > TOPO_METH_REPLACED_VERSION) | |
468 return (topo_mod_seterrno(mod, EMOD_VER_NEW)); | |
469 | |
470 if (nvlist_lookup_uint8(in, FM_VERSION, &fmversion) != 0 || | |
471 fmversion > FM_DEV_SCHEME_VERSION || | |
472 nvlist_lookup_string(in, FM_FMRI_DEV_PATH, &devpath) != 0) | |
473 return (topo_mod_seterrno(mod, EMOD_FMRI_MALFORM)); | |
474 | |
475 (void) nvlist_lookup_string(in, FM_FMRI_DEV_ID, &devid); | |
476 | |
477 if (devpath == NULL || strlen(devpath) == 0) | |
478 return (topo_mod_seterrno(mod, EMOD_FMRI_MALFORM)); | |
479 | |
480 /* | |
481 * stat() the device node in devfs. This will tell us if the device is | |
482 * present or not. Don't stat the minor, just the whole device. | |
483 * If the device is present and there is a devid, it must also match. | |
484 * so di_init that one node. No need for DINFOFORCE. | |
485 */ | |
486 len = strlen(devpath) + strlen("/devices") + 1; | |
487 path = topo_mod_alloc(mod, len); | |
488 (void) snprintf(path, len, "/devices%s", devpath); | |
489 if (devid == NULL) { | |
490 if (stat(path, &sb) != -1) | |
491 rval = FMD_OBJ_STATE_UNKNOWN; | |
492 else if ((dnode = di_init("/", DINFOCACHE)) == DI_NODE_NIL) | |
12618
0e5eaf4bf546
6935604 io-retire should prevent attach of faulty persistent devices
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents:
12213
diff
changeset
|
493 rval = FMD_OBJ_STATE_UNKNOWN; |
7275 | 494 else { |
495 if (di_lookup_node(dnode, devpath) == DI_NODE_NIL) | |
12618
0e5eaf4bf546
6935604 io-retire should prevent attach of faulty persistent devices
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents:
12213
diff
changeset
|
496 rval = FMD_OBJ_STATE_UNKNOWN; |
7275 | 497 else |
498 rval = FMD_OBJ_STATE_UNKNOWN; | |
499 di_fini(dnode); | |
500 } | |
501 } else { | |
502 if (stat(path, &sb) == -1) | |
12618
0e5eaf4bf546
6935604 io-retire should prevent attach of faulty persistent devices
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents:
12213
diff
changeset
|
503 rval = FMD_OBJ_STATE_UNKNOWN; |
7275 | 504 else if ((dnode = di_init(devpath, DINFOCPYONE)) == DI_NODE_NIL) |
12618
0e5eaf4bf546
6935604 io-retire should prevent attach of faulty persistent devices
Stephen Hanson <Stephen.Hanson@Sun.COM>
parents:
12213
diff
changeset
|
505 rval = FMD_OBJ_STATE_UNKNOWN; |
7275 | 506 else { |
507 if ((id = di_devid(dnode)) == NULL || | |
508 devid_str_decode(devid, &matchid, NULL) != 0) | |
509 rval = FMD_OBJ_STATE_UNKNOWN; | |
510 else { | |
511 if (devid_compare(id, matchid) != 0) | |
512 rval = FMD_OBJ_STATE_REPLACED; | |
513 else | |
514 rval = FMD_OBJ_STATE_STILL_PRESENT; | |
515 devid_free(matchid); | |
516 } | |
517 di_fini(dnode); | |
518 } | |
519 } | |
520 topo_mod_free(mod, path, len); | |
521 | |
522 if (topo_mod_nvalloc(mod, out, NV_UNIQUE_NAME) != 0) | |
523 return (topo_mod_seterrno(mod, EMOD_NVL_INVAL)); | |
524 if (nvlist_add_uint32(*out, TOPO_METH_REPLACED_RET, rval) != 0) { | |
525 nvlist_free(*out); | |
526 return (topo_mod_seterrno(mod, EMOD_NVL_INVAL)); | |
527 } | |
528 | |
529 return (0); | |
530 } | |
531 | |
532 /*ARGSUSED*/ | |
533 static int | |
4198
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
534 dev_fmri_unusable(topo_mod_t *mod, tnode_t *node, topo_version_t version, |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
535 nvlist_t *in, nvlist_t **out) |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
536 { |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
537 di_node_t dnode; |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
538 uint8_t fmversion; |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
539 char *devpath = NULL; |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
540 uint32_t unusable; |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
541 uint_t state; |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
542 |
7275 | 543 if (version > TOPO_METH_UNUSABLE_VERSION) |
4198
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
544 return (topo_mod_seterrno(mod, EMOD_VER_NEW)); |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
545 |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
546 if (nvlist_lookup_uint8(in, FM_VERSION, &fmversion) != 0 || |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
547 fmversion > FM_DEV_SCHEME_VERSION || |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
548 nvlist_lookup_string(in, FM_FMRI_DEV_PATH, &devpath) != 0) |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
549 return (topo_mod_seterrno(mod, EMOD_FMRI_MALFORM)); |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
550 |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
551 if (devpath == NULL) |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
552 return (topo_mod_seterrno(mod, EMOD_FMRI_MALFORM)); |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
553 |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
554 if ((dnode = di_init(devpath, DINFOCPYONE)) == DI_NODE_NIL) { |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
555 if (errno != ENXIO) |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
556 return (topo_mod_seterrno(mod, EMOD_UKNOWN_ENUM)); |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
557 unusable = 1; |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
558 } else { |
4845 | 559 uint_t retired = di_retired(dnode); |
4198
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
560 state = di_state(dnode); |
4845 | 561 if (retired || (state & (DI_DEVICE_OFFLINE | DI_DEVICE_DOWN | |
562 DI_BUS_QUIESCED | DI_BUS_DOWN))) | |
4198
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
563 unusable = 1; |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
564 else |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
565 unusable = 0; |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
566 di_fini(dnode); |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
567 } |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
568 |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
569 if (topo_mod_nvalloc(mod, out, NV_UNIQUE_NAME) != 0) |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
570 return (topo_mod_seterrno(mod, EMOD_NVL_INVAL)); |
4444
558de447355b
6568015 libtopo sets wrong return value for dev scheme's unusable method
vikram
parents:
4198
diff
changeset
|
571 if (nvlist_add_uint32(*out, TOPO_METH_UNUSABLE_RET, unusable) != 0) { |
4198
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
572 nvlist_free(*out); |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
573 return (topo_mod_seterrno(mod, EMOD_NVL_INVAL)); |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
574 } |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
575 |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
576 return (0); |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
577 } |
6bdfb19526db
PSARC 2007/202 FMA Generic Disk Monitoring Events
eschrock
parents:
3062
diff
changeset
|
578 |
7275 | 579 /*ARGSUSED*/ |
580 static int | |
581 dev_fmri_service_state(topo_mod_t *mod, tnode_t *node, topo_version_t version, | |
582 nvlist_t *in, nvlist_t **out) | |
583 { | |
584 di_node_t dnode; | |
585 uint8_t fmversion; | |
586 char *devpath = NULL; | |
587 uint32_t service_state; | |
588 uint_t state; | |
589 | |
590 if (version > TOPO_METH_SERVICE_STATE_VERSION) | |
591 return (topo_mod_seterrno(mod, EMOD_VER_NEW)); | |
592 | |
593 if (nvlist_lookup_uint8(in, FM_VERSION, &fmversion) != 0 || | |
594 fmversion > FM_DEV_SCHEME_VERSION || | |
595 nvlist_lookup_string(in, FM_FMRI_DEV_PATH, &devpath) != 0) | |
596 return (topo_mod_seterrno(mod, EMOD_FMRI_MALFORM)); | |
597 | |
598 if (devpath == NULL) | |
599 return (topo_mod_seterrno(mod, EMOD_FMRI_MALFORM)); | |
600 | |
601 if ((dnode = di_init(devpath, DINFOCPYONE)) == DI_NODE_NIL) { | |
602 if (errno != ENXIO) | |
603 return (topo_mod_seterrno(mod, EMOD_UKNOWN_ENUM)); | |
604 service_state = FMD_SERVICE_STATE_UNUSABLE; | |
605 } else { | |
606 uint_t retired = di_retired(dnode); | |
607 state = di_state(dnode); | |
608 if (retired || (state & (DI_DEVICE_OFFLINE | DI_DEVICE_DOWN | | |
609 DI_BUS_QUIESCED | DI_BUS_DOWN))) | |
610 service_state = FMD_SERVICE_STATE_UNUSABLE; | |
611 else if (state & DI_DEVICE_DEGRADED) | |
612 service_state = FMD_SERVICE_STATE_DEGRADED; | |
613 else | |
614 service_state = FMD_SERVICE_STATE_OK; | |
615 di_fini(dnode); | |
616 } | |
617 | |
618 if (topo_mod_nvalloc(mod, out, NV_UNIQUE_NAME) != 0) | |
619 return (topo_mod_seterrno(mod, EMOD_NVL_INVAL)); | |
620 if (nvlist_add_uint32(*out, TOPO_METH_SERVICE_STATE_RET, | |
621 service_state) != 0) { | |
622 nvlist_free(*out); | |
623 return (topo_mod_seterrno(mod, EMOD_NVL_INVAL)); | |
624 } | |
625 | |
626 return (0); | |
627 } | |
628 | |
1541
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
629 static nvlist_t * |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
630 dev_fmri_create(topo_mod_t *mp, const char *id, const char *path) |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
631 { |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
632 nvlist_t *out = NULL; |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
633 int e; |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
634 |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
635 if (topo_mod_nvalloc(mp, &out, NV_UNIQUE_NAME) != 0) { |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
636 (void) topo_mod_seterrno(mp, EMOD_FMRI_NVL); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
637 return (NULL); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
638 } |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
639 e = nvlist_add_string(out, FM_FMRI_SCHEME, FM_FMRI_SCHEME_DEV); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
640 e |= nvlist_add_uint8(out, FM_VERSION, FM_DEV_SCHEME_VERSION); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
641 e |= nvlist_add_string(out, FM_FMRI_DEV_PATH, path); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
642 |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
643 if (id != NULL) |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
644 e |= nvlist_add_string(out, FM_FMRI_DEV_ID, id); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
645 |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
646 if (e == 0) |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
647 return (out); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
648 |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
649 topo_mod_dprintf(mp, "construction of dev nvl failed"); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
650 (void) topo_mod_seterrno(mp, EMOD_FMRI_NVL); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
651 nvlist_free(out); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
652 return (NULL); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
653 } |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
654 |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
655 /*ARGSUSED*/ |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
656 static int |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
657 dev_fmri_create_meth(topo_mod_t *mp, tnode_t *node, topo_version_t version, |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
658 nvlist_t *in, nvlist_t **out) |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
659 { |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
660 nvlist_t *args = NULL; |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
661 char *path, *id = NULL; |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
662 |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
663 if (version > TOPO_METH_FMRI_VERSION) |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
664 return (topo_mod_seterrno(mp, EMOD_VER_NEW)); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
665 |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
666 if (nvlist_lookup_nvlist(in, TOPO_METH_FMRI_ARG_NVL, &args) != 0 || |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
667 nvlist_lookup_string(args, FM_FMRI_DEV_PATH, &path) != 0) { |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
668 topo_mod_dprintf(mp, "no path string in method argument\n"); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
669 return (topo_mod_seterrno(mp, EMOD_METHOD_INVAL)); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
670 } |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
671 |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
672 (void) nvlist_lookup_string(args, FM_FMRI_DEV_ID, &id); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
673 |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
674 if ((*out = dev_fmri_create(mp, id, path)) == NULL) |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
675 return (-1); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
676 return (0); |
1eda9cf84032
6390709 bfu should eradicate the now-obsolete fm/libtopo_enum.h
timh
parents:
diff
changeset
|
677 } |