topo_snap.c (e5dcf7be) topo_snap.c (c93c462e)
1/*
2 * CDDL HEADER START
3 *
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.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 271 unchanged lines hidden (view full) ---

280 topo_dprintf(thp, TOPO_DBG_ERR, "unable to allocate uuid: %s\n",
281 topo_strerror(*errp));
282 topo_hdl_unlock(thp);
283 return (NULL);
284 }
285
286 uuid_generate(uuid);
287 uuid_unparse(uuid, thp->th_uuid);
1/*
2 * CDDL HEADER START
3 *
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.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 271 unchanged lines hidden (view full) ---

280 topo_dprintf(thp, TOPO_DBG_ERR, "unable to allocate uuid: %s\n",
281 topo_strerror(*errp));
282 topo_hdl_unlock(thp);
283 return (NULL);
284 }
285
286 uuid_generate(uuid);
287 uuid_unparse(uuid, thp->th_uuid);
288 if ((ustr = topo_hdl_strdup(thp, thp->th_uuid)) == NULL) {
289 *errp = ETOPO_NOMEM;
290 topo_hdl_unlock(thp);
291 return (NULL);
292 }
288
293
294 thp->th_di = di_init("/", DI_CACHE_SNAPSHOT_FLAGS | DINFOCLEANUP);
295 thp->th_pi = di_prom_init();
296
289 if (topo_tree_enum_all(thp) < 0) {
290 topo_dprintf(thp, TOPO_DBG_ERR, "enumeration failure: %s\n",
291 topo_hdl_errmsg(thp));
292 if (topo_hdl_errno(thp) == ETOPO_ENUM_FATAL) {
293 *errp = thp->th_errno;
297 if (topo_tree_enum_all(thp) < 0) {
298 topo_dprintf(thp, TOPO_DBG_ERR, "enumeration failure: %s\n",
299 topo_hdl_errmsg(thp));
300 if (topo_hdl_errno(thp) == ETOPO_ENUM_FATAL) {
301 *errp = thp->th_errno;
302
303 if (thp->th_di != DI_NODE_NIL) {
304 di_fini(thp->th_di);
305 thp->th_di = DI_NODE_NIL;
306 }
307 if (thp->th_pi != DI_PROM_HANDLE_NIL) {
308 di_prom_fini(thp->th_pi);
309 thp->th_pi = DI_PROM_HANDLE_NIL;
310 }
311
312 topo_hdl_strfree(thp, ustr);
294 topo_hdl_unlock(thp);
295 return (NULL);
296 }
297 }
298
299 if (thp->th_ipmi != NULL &&
300 ipmi_sdr_changed(thp->th_ipmi) &&
301 ipmi_sdr_refresh(thp->th_ipmi) != 0) {
302 topo_dprintf(thp, TOPO_DBG_ERR,
303 "failed to refresh IPMI sdr repository: %s\n",
304 ipmi_errmsg(thp->th_ipmi));
305 }
306
313 topo_hdl_unlock(thp);
314 return (NULL);
315 }
316 }
317
318 if (thp->th_ipmi != NULL &&
319 ipmi_sdr_changed(thp->th_ipmi) &&
320 ipmi_sdr_refresh(thp->th_ipmi) != 0) {
321 topo_dprintf(thp, TOPO_DBG_ERR,
322 "failed to refresh IPMI sdr repository: %s\n",
323 ipmi_errmsg(thp->th_ipmi));
324 }
325
307 if ((ustr = topo_hdl_strdup(thp, thp->th_uuid)) == NULL)
308 *errp = ETOPO_NOMEM;
309
310 thp->th_di = DI_NODE_NIL;
311 thp->th_pi = DI_PROM_HANDLE_NIL;
312
313 topo_hdl_unlock(thp);
314
315 return (ustr);
316}
317
318/*ARGSUSED*/
319static char *
320topo_snap_log_create(topo_hdl_t *thp, const char *uuid, int *errp)

--- 111 unchanged lines hidden (view full) ---

432 nhp->th_arrlen * sizeof (tnode_t *));
433 topo_list_delete(&root->tn_children, nhp);
434 topo_mod_free(mod, nhp, sizeof (topo_nodehash_t));
435 topo_mod_rele(mod);
436 }
437
438 }
439
326 topo_hdl_unlock(thp);
327
328 return (ustr);
329}
330
331/*ARGSUSED*/
332static char *
333topo_snap_log_create(topo_hdl_t *thp, const char *uuid, int *errp)

--- 111 unchanged lines hidden (view full) ---

445 nhp->th_arrlen * sizeof (tnode_t *));
446 topo_list_delete(&root->tn_children, nhp);
447 topo_mod_free(mod, nhp, sizeof (topo_nodehash_t));
448 topo_mod_rele(mod);
449 }
450
451 }
452
453 /*
454 * Clean-up our cached devinfo and prom tree handles.
455 */
456 if (thp->th_di != DI_NODE_NIL) {
457 di_fini(thp->th_di);
458 thp->th_di = DI_NODE_NIL;
459 }
460 if (thp->th_pi != DI_PROM_HANDLE_NIL) {
461 di_prom_fini(thp->th_pi);
462 thp->th_pi = DI_PROM_HANDLE_NIL;
463 }
464
465
440 if (thp->th_uuid != NULL) {
441 topo_hdl_free(thp, thp->th_uuid, TOPO_UUID_SIZE);
442 thp->th_uuid = NULL;
443 }
444}
445
446void
447topo_snap_release(topo_hdl_t *thp)

--- 258 unchanged lines hidden (view full) ---

706 else
707 status = step_child(cnp, wp, flag, 1);
708 }
709
710 topo_node_rele(cnp); /* done with current node */
711
712 return (status);
713}
466 if (thp->th_uuid != NULL) {
467 topo_hdl_free(thp, thp->th_uuid, TOPO_UUID_SIZE);
468 thp->th_uuid = NULL;
469 }
470}
471
472void
473topo_snap_release(topo_hdl_t *thp)

--- 258 unchanged lines hidden (view full) ---

732 else
733 status = step_child(cnp, wp, flag, 1);
734 }
735
736 topo_node_rele(cnp); /* done with current node */
737
738 return (status);
739}
740
741di_node_t
742topo_hdl_devinfo(topo_hdl_t *thp)
743{
744 return (thp == NULL ? DI_NODE_NIL : thp->th_di);
745}
746
747di_prom_handle_t
748topo_hdl_prominfo(topo_hdl_t *thp)
749{
750 return (thp == NULL ? DI_PROM_HANDLE_NIL : thp->th_pi);
751}