4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
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.
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]
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #include "cfga_scsi.h"
29 * This file contains the entry points to the plug-in as defined in the
30 * config_admin(3X) man page.
34 * Set the version number
36 int cfga_version
= CFGA_HSL_V2
;
39 * For debugging - higher values increase verbosity
43 #pragma init(_cfgadm_scsi_init)
50 if (tstr
= getenv("SCFGA_DEBUG")) {
51 _scfga_debug
= atoi(tstr
);
58 cfga_cmd_t state_change_cmd
,
61 struct cfga_confirm
*confp
,
62 struct cfga_msg
*msgp
,
66 apid_t apidt
= {NULL
};
69 if (errstring
!= NULL
) {
74 * All sub-commands which can change state of device require
81 if (options
!= NULL
&& strcmp(options
, OPT_DISABLE_RCM
) != 0) {
82 cfga_err(errstring
, 0, ERRARG_OPT_INVAL
, options
, 0);
86 if ((ret
= apidt_create(ap_id
, &apidt
, errstring
)) != SCFGA_OK
) {
87 return (err_cvt(ret
));
91 apidt
.flags
|= FLAG_DISABLE_RCM
;
93 /* A dynamic component indicates a device, else it is the bus */
94 if (apidt
.dyncomp
!= NULL
) {
95 ret
= dev_change_state(state_change_cmd
, &apidt
, flags
,
98 ret
= bus_change_state(state_change_cmd
, &apidt
, confp
, flags
,
103 return (err_cvt(ret
));
112 struct cfga_confirm
*confp
,
113 struct cfga_msg
*msgp
,
117 apid_t apidt
= {NULL
};
118 prompt_t args
= {NULL
};
121 if (errstring
!= NULL
)
124 if (geteuid() != 0) {
132 if (options
!= NULL
&& strcmp(options
, OPT_DISABLE_RCM
) != 0) {
133 cfga_err(errstring
, 0, ERRARG_OPT_INVAL
, options
, 0);
137 if ((ret
= apidt_create(ap_id
, &apidt
, errstring
)) != SCFGA_OK
) {
138 return (err_cvt(ret
));
141 if (apidt
.dyntype
== PATH_APID
) {
142 return (CFGA_OPNOTSUPP
);
146 apidt
.flags
|= FLAG_DISABLE_RCM
;
154 ret
= invoke_cmd(func
, &apidt
, &args
, flags
, errstring
);
157 return (err_cvt(ret
));
165 struct cfga_msg
*msgp
,
169 if (errstring
!= NULL
) {
173 if (geteuid() != 0) {
177 return (CFGA_OPNOTSUPP
);
184 cfga_list_data_t
**ap_id_list
,
187 const char *listopts
,
191 int hba
, expand
, nelem
;
192 ldata_list_t
*llp
= NULL
;
193 apid_t apidt
= {NULL
};
197 if (errstring
!= NULL
) {
201 if (ap_id_list
== NULL
|| nlistp
== NULL
) {
209 * There is no RCM involvement in "list" operations.
210 * The only supported option is OPT_USE_DIFORCE.
212 if (options
!= NULL
&& strcmp(options
, OPT_USE_DIFORCE
) != 0) {
213 cfga_err(errstring
, 0, ERRARG_OPT_INVAL
, options
, 0);
218 if (GET_DYN(ap_id
) == NULL
) {
223 if ((flags
& CFGA_FLAG_LIST_ALL
) == CFGA_FLAG_LIST_ALL
) {
228 * We expand published attachment points but not
229 * dynamic attachment points
232 if (!hba
) { /* Stat a single device - no expansion for devices */
233 cmd
= SCFGA_STAT_DEV
;
234 } else if (!expand
) { /* Stat only the HBA */
235 cmd
= SCFGA_STAT_BUS
;
236 } else { /* Expand HBA attachment point */
237 cmd
= SCFGA_STAT_ALL
;
240 if ((ret
= apidt_create(ap_id
, &apidt
, errstring
)) != SCFGA_OK
) {
241 return (err_cvt(ret
));
245 * Currently only 1 option supported
248 apidt
.flags
|= FLAG_USE_DIFORCE
;
253 ret
= do_list(&apidt
, cmd
, &llp
, &nelem
, errstring
);
254 if (ret
!= SCFGA_OK
) {
260 if (list_ext_postprocess(&llp
, nelem
, ap_id_list
, nlistp
,
261 errstring
) != SCFGA_OK
) {
262 assert(*ap_id_list
== NULL
&& *nlistp
== 0);
265 assert(*ap_id_list
!= NULL
&& *nlistp
== nelem
);
273 return (err_cvt(ret
));
279 cfga_help(struct cfga_msg
*msgp
, const char *options
, cfga_flags_t flags
)
281 cfga_msg(msgp
, MSG_HELP_HDR
, MSG_HELP_USAGE
, 0);
287 * cfga_ap_id_cmp -- use default_ap_id_cmp() in libcfgadm