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 2003 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
32 #include <libdevinfo.h>
33 #define CFGA_PLUGIN_LIB
34 #include <config_admin.h>
37 int cfga_version
= CFGA_HSL_V2
;
45 struct cfga_confirm
*confp
,
46 struct cfga_msg
*msgp
,
55 if ((rc
= ap_state_cmd(cfga_cmd
, &cmd
)) != CFGA_OK
)
60 if ((a
= apd_alloc(ap_id
, flags
, errstring
, msgp
, confp
)) == NULL
)
63 name
= ap_cmd_name(cmd
);
65 if ((rc
= ap_cmd_parse(a
, name
, options
, NULL
)) == CFGA_OK
)
66 rc
= ap_cmd_seq(a
, cmd
);
74 * Check if this is a valid -x command.
77 private_func(const char *function
)
91 for (f
= private_funcs
; *f
!= NULL
; f
++)
92 if (strcmp(*f
, function
) == 0)
95 return (*f
== NULL
? CFGA_INVAL
: CFGA_OK
);
101 const char *function
,
104 struct cfga_confirm
*confp
,
105 struct cfga_msg
*msgp
,
113 DBG("cfga_private_func(%s)\n", ap_id
);
117 if ((a
= apd_alloc(ap_id
, flags
, errstring
, msgp
, confp
)) == NULL
)
119 else if ((rc
= private_func(function
)) != CFGA_OK
) {
120 ap_err(a
, ERR_CMD_INVAL
, function
);
122 } else if ((rc
= ap_cmd_parse(a
, function
, options
, &cmd
)) != CFGA_OK
)
124 else if (cmd
== CMD_ERRTEST
)
125 rc
= ap_test_err(a
, options
);
127 rc
= ap_cmd_exec(a
, cmd
);
139 struct cfga_msg
*msgp
,
148 DBG("cfga_test(%s)\n", ap_id
);
154 * A test that is not sequenced by a change
155 * state operation should be forced.
157 flags
|= CFGA_FLAG_FORCE
;
159 if ((a
= apd_alloc(ap_id
, flags
, errstring
, msgp
, NULL
)) == NULL
)
161 else if ((rc
= ap_cmd_parse(a
, f
, options
, &cmd
)) != CFGA_OK
)
164 rc
= ap_cmd_exec(a
, cmd
);
174 cfga_list_data_t
**ap_id_list
,
177 const char *listopts
,
186 cfga_list_data_t
*aplist
, *ap
;
192 f
= ap_cmd_name(CMD_STATUS
);
194 DBG("cfga_list_ext(%s %x)\n", ap_id
, flags
);
196 if ((a
= apd_alloc(ap_id
, flags
, errstring
, NULL
, NULL
)) == NULL
)
198 else if ((rc
= ap_cmd_parse(a
, f
, options
, NULL
)) != CFGA_OK
)
203 DBG("apcnt=%d\n", apcnt
);
205 if ((aplist
= calloc(apcnt
, sizeof (*aplist
))) == NULL
) {
207 ap_err(a
, ERR_CMD_FAIL
, CMD_STATUS
);
212 szl
= sizeof (ap
->ap_log_id
);
213 szp
= sizeof (ap
->ap_phys_id
);
216 * Initialize the AP specified directly by the caller.
217 * The target ID for the 0th element already includes
218 * the (potential) dynamic portion. The dynamic portion
219 * does need to be appended to the path to form the
220 * physical apid for components.
222 (void) strncpy(ap
->ap_log_id
, a
->target
, szl
- 1);
223 (void) snprintf(ap
->ap_phys_id
, szp
, "%s%s%s", a
->path
,
224 a
->tgt
!= AP_BOARD
? "::" : "",
225 a
->tgt
!= AP_BOARD
? a
->cid
: "");
228 DBG("ap_phys_id=%s ap_log_id=%s\n", ap
->ap_phys_id
, ap
->ap_log_id
);
230 if (a
->tgt
== AP_BOARD
) {
235 * Initialize the components, if any.
237 for (i
= 0; i
< apcnt
- 1; i
++, ap
++) {
238 char dyn
[MAXPATHLEN
];
240 ap_cm_id(a
, i
, dyn
, sizeof (dyn
));
242 (void) snprintf(ap
->ap_log_id
, szl
, "%s::%s",
244 (void) snprintf(ap
->ap_phys_id
, szp
, "%s::%s",
247 ap_cm_init(a
, ap
, i
);
249 DBG("ap_phys_id=%s ap_log_id=%s\n",
250 ap
->ap_phys_id
, ap
->ap_log_id
);
254 ap_cm_init(a
, ap
, 0);
257 *ap_id_list
= aplist
;
269 cfga_help(struct cfga_msg
*msgp
, const char *options
, cfga_flags_t flags
)
271 return (ap_help(msgp
, options
, flags
));
276 * cfga_ap_id_cmp -- use default_ap_id_cmp() in libcfgadm