Lines Matching defs:handle

65 /* NDMP scf handle structure */
376 ndmp_scfhandle_t *handle = NULL;
384 if ((handle = ndmp_smf_scf_init(NDMP_GROUP_FMRI_PREFIX)) == NULL) {
388 if (ndmp_smf_get_pg_name(handle, prop, &pgname)) {
393 if (ndmp_smf_create_service_pgroup(handle, pgname)) {
394 ndmp_smf_scf_fini(handle);
398 if (ndmp_smf_get_property(handle, prop, lval, NDMP_PROP_LEN) != 0) {
399 ndmp_smf_scf_fini(handle);
405 ndmp_smf_scf_fini(handle);
412 ndmp_scfhandle_t *handle = NULL;
418 if ((handle = ndmp_smf_scf_init(NDMP_GROUP_FMRI_PREFIX)) == NULL)
421 if (ndmp_smf_get_pg_name(handle, env, &pgname)) {
426 if (ndmp_smf_create_service_pgroup(handle, pgname))
429 if (ndmp_smf_start_transaction(handle))
440 if (ndmp_smf_set_property(handle, env, lval)) {
444 if (ndmp_smf_delete_property(handle, env))
448 if (ndmp_config_saveenv(handle) != 0)
499 ndmp_config_saveenv(ndmp_scfhandle_t *handle)
503 ret = ndmp_smf_end_transaction(handle);
505 ndmp_smf_scf_fini(handle);
510 * Must be called when done. Called with the handle allocated in
515 ndmp_smf_scf_fini(ndmp_scfhandle_t *handle)
517 if (handle != NULL) {
518 scf_scope_destroy(handle->scf_scope);
519 scf_service_destroy(handle->scf_service);
520 scf_pg_destroy(handle->scf_pg);
521 handle->scf_state = NDMP_SCH_STATE_UNINIT;
522 (void) scf_handle_unbind(handle->scf_handle);
523 scf_handle_destroy(handle->scf_handle);
524 free(handle);
535 ndmp_scfhandle_t *handle;
537 handle = (ndmp_scfhandle_t *)calloc(1, sizeof (ndmp_scfhandle_t));
538 if (handle != NULL) {
539 handle->scf_state = NDMP_SCH_STATE_INITIALIZING;
540 if (((handle->scf_handle =
542 (scf_handle_bind(handle->scf_handle) == 0)) {
543 if ((handle->scf_scope =
544 scf_scope_create(handle->scf_handle)) == NULL)
547 if (scf_handle_get_local_scope(handle->scf_handle,
548 handle->scf_scope) != 0)
551 if ((handle->scf_service =
552 scf_service_create(handle->scf_handle)) == NULL)
555 if (scf_scope_get_service(handle->scf_scope, svc_name,
556 handle->scf_service) != SCF_SUCCESS)
559 if ((handle->scf_pg =
560 scf_pg_create(handle->scf_handle)) == NULL)
563 handle->scf_state = NDMP_SCH_STATE_INIT;
569 handle = NULL;
571 return (handle);
575 (void) ndmp_smf_scf_fini(handle);
584 ndmp_smf_create_service_pgroup(ndmp_scfhandle_t *handle, char *pgroup)
589 * Only create a handle if it doesn't exist. It is ok to exist since
590 * the pg handle will be set as a side effect.
592 if (handle->scf_pg == NULL) {
593 if ((handle->scf_pg =
594 scf_pg_create(handle->scf_handle)) == NULL)
603 if (scf_service_get_pg(handle->scf_service,
604 pgroup, handle->scf_pg) != 0) {
606 if (scf_service_add_pg(handle->scf_service, pgroup,
607 SCF_GROUP_FRAMEWORK, 0, handle->scf_pg) != 0) {
627 * Start transaction on current pg in handle. The pg could be service or
628 * instance level. Must be called after pg handle is obtained from create or
632 ndmp_smf_start_transaction(ndmp_scfhandle_t *handle)
638 if (handle->scf_state == NDMP_SCH_STATE_INIT) {
639 if ((handle->scf_trans =
640 scf_transaction_create(handle->scf_handle)) != NULL) {
641 if (scf_transaction_start(handle->scf_trans,
642 handle->scf_pg) != 0) {
643 scf_transaction_destroy(handle->scf_trans);
644 handle->scf_trans = NULL;
662 * Commit the changes that were added to the transaction in the handle. Do all
666 ndmp_smf_end_transaction(ndmp_scfhandle_t *handle)
668 if (scf_transaction_commit(handle->scf_trans) < 0) {
673 scf_transaction_destroy_children(handle->scf_trans);
674 scf_transaction_destroy(handle->scf_trans);
675 handle->scf_trans = NULL;
684 ndmp_smf_delete_property(ndmp_scfhandle_t *handle, char *propname)
692 if ((entry = scf_entry_create(handle->scf_handle)) != NULL) {
693 if (scf_transaction_property_delete(handle->scf_trans, entry,
716 ndmp_smf_set_property(ndmp_scfhandle_t *handle,
731 if (((value = scf_value_create(handle->scf_handle)) != NULL) &&
732 (entry = scf_entry_create(handle->scf_handle)) != NULL) {
734 scf_property_create(handle->scf_handle)) != NULL) &&
735 ((scf_pg_get_property(handle->scf_pg, propname,
740 handle->scf_trans, entry, propname,
743 handle->scf_trans, entry, propname,
803 ndmp_smf_get_property(ndmp_scfhandle_t *handle, char *propname,
814 if (((value = scf_value_create(handle->scf_handle)) != NULL) &&
815 ((prop = scf_property_create(handle->scf_handle)) != NULL) &&
816 (scf_pg_get_property(handle->scf_pg, propname, prop) == 0)) {