Lines Matching refs:handle

112 	ndmp_scfhandle_t *handle;  in ndmp_get_prop()  local
117 if ((handle = ndmp_smf_scf_init(NDMP_GROUP_FMRI_PREFIX)) == NULL) { in ndmp_get_prop()
120 if (ndmp_smf_get_pg_name(handle, prop, &pgname)) { in ndmp_get_prop()
121 ndmp_smf_scf_fini(handle); in ndmp_get_prop()
125 if (ndmp_smf_create_service_pgroup(handle, pgname)) { in ndmp_get_prop()
126 ndmp_smf_scf_fini(handle); in ndmp_get_prop()
130 ndmp_smf_scf_fini(handle); in ndmp_get_prop()
134 if (ndmp_smf_get_property(handle, prop, lval, NDMP_PROP_LEN) != 0) { in ndmp_get_prop()
135 ndmp_smf_scf_fini(handle); in ndmp_get_prop()
141 ndmp_smf_scf_fini(handle); in ndmp_get_prop()
148 ndmp_scfhandle_t *handle; in ndmp_set_prop() local
152 if ((handle = ndmp_smf_scf_init(NDMP_GROUP_FMRI_PREFIX)) == NULL) in ndmp_set_prop()
155 if (ndmp_smf_get_pg_name(handle, env, &pgname)) { in ndmp_set_prop()
156 ndmp_smf_scf_fini(handle); in ndmp_set_prop()
161 if (ndmp_smf_create_service_pgroup(handle, pgname)) { in ndmp_set_prop()
162 ndmp_smf_scf_fini(handle); in ndmp_set_prop()
166 if (ndmp_smf_start_transaction(handle)) { in ndmp_set_prop()
167 ndmp_smf_scf_fini(handle); in ndmp_set_prop()
172 rc = ndmp_smf_set_property(handle, env, env_val); in ndmp_set_prop()
174 rc = ndmp_smf_delete_property(handle, env); in ndmp_set_prop()
176 if (ndmp_config_saveenv(handle, (rc == 0)) == 0) in ndmp_set_prop()
223 ndmp_config_saveenv(ndmp_scfhandle_t *handle, boolean_t commit) in ndmp_config_saveenv() argument
227 ret = ndmp_smf_end_transaction(handle, commit); in ndmp_config_saveenv()
229 ndmp_smf_scf_fini(handle); in ndmp_config_saveenv()
239 ndmp_smf_scf_fini(ndmp_scfhandle_t *handle) in ndmp_smf_scf_fini() argument
241 if (handle == NULL) in ndmp_smf_scf_fini()
244 scf_scope_destroy(handle->scf_scope); in ndmp_smf_scf_fini()
245 scf_service_destroy(handle->scf_service); in ndmp_smf_scf_fini()
246 scf_pg_destroy(handle->scf_pg); in ndmp_smf_scf_fini()
247 handle->scf_state = NDMP_SCH_STATE_UNINIT; in ndmp_smf_scf_fini()
248 (void) scf_handle_unbind(handle->scf_handle); in ndmp_smf_scf_fini()
249 scf_handle_destroy(handle->scf_handle); in ndmp_smf_scf_fini()
250 free(handle); in ndmp_smf_scf_fini()
260 ndmp_scfhandle_t *handle; in ndmp_smf_scf_init() local
262 handle = (ndmp_scfhandle_t *)calloc(1, sizeof (ndmp_scfhandle_t)); in ndmp_smf_scf_init()
263 if (handle != NULL) { in ndmp_smf_scf_init()
264 handle->scf_state = NDMP_SCH_STATE_INITIALIZING; in ndmp_smf_scf_init()
265 if (((handle->scf_handle = in ndmp_smf_scf_init()
267 (scf_handle_bind(handle->scf_handle) == 0)) { in ndmp_smf_scf_init()
268 if ((handle->scf_scope = in ndmp_smf_scf_init()
269 scf_scope_create(handle->scf_handle)) == NULL) in ndmp_smf_scf_init()
272 if (scf_handle_get_local_scope(handle->scf_handle, in ndmp_smf_scf_init()
273 handle->scf_scope) != 0) in ndmp_smf_scf_init()
276 if ((handle->scf_service = in ndmp_smf_scf_init()
277 scf_service_create(handle->scf_handle)) == NULL) in ndmp_smf_scf_init()
280 if (scf_scope_get_service(handle->scf_scope, svc_name, in ndmp_smf_scf_init()
281 handle->scf_service) != SCF_SUCCESS) in ndmp_smf_scf_init()
284 if ((handle->scf_pg = in ndmp_smf_scf_init()
285 scf_pg_create(handle->scf_handle)) == NULL) in ndmp_smf_scf_init()
288 handle->scf_state = NDMP_SCH_STATE_INIT; in ndmp_smf_scf_init()
294 handle = NULL; in ndmp_smf_scf_init()
296 return (handle); in ndmp_smf_scf_init()
300 (void) ndmp_smf_scf_fini(handle); in ndmp_smf_scf_init()
309 ndmp_smf_create_service_pgroup(ndmp_scfhandle_t *handle, const char *pgroup) in ndmp_smf_create_service_pgroup() argument
317 if (handle->scf_pg == NULL) { in ndmp_smf_create_service_pgroup()
318 if ((handle->scf_pg = in ndmp_smf_create_service_pgroup()
319 scf_pg_create(handle->scf_handle)) == NULL) { in ndmp_smf_create_service_pgroup()
329 if (scf_service_get_pg(handle->scf_service, in ndmp_smf_create_service_pgroup()
330 pgroup, handle->scf_pg) != 0) { in ndmp_smf_create_service_pgroup()
332 if (scf_service_add_pg(handle->scf_service, pgroup, in ndmp_smf_create_service_pgroup()
333 SCF_GROUP_FRAMEWORK, 0, handle->scf_pg) != 0) { in ndmp_smf_create_service_pgroup()
354 ndmp_smf_start_transaction(ndmp_scfhandle_t *handle) in ndmp_smf_start_transaction() argument
360 if (handle->scf_state == NDMP_SCH_STATE_INIT) { in ndmp_smf_start_transaction()
361 if ((handle->scf_trans = in ndmp_smf_start_transaction()
362 scf_transaction_create(handle->scf_handle)) != NULL) { in ndmp_smf_start_transaction()
363 if (scf_transaction_start(handle->scf_trans, in ndmp_smf_start_transaction()
364 handle->scf_pg) != 0) { in ndmp_smf_start_transaction()
365 scf_transaction_destroy(handle->scf_trans); in ndmp_smf_start_transaction()
366 handle->scf_trans = NULL; in ndmp_smf_start_transaction()
388 ndmp_smf_end_transaction(ndmp_scfhandle_t *handle, boolean_t commit) in ndmp_smf_end_transaction() argument
393 if (scf_transaction_commit(handle->scf_trans) < 0) { in ndmp_smf_end_transaction()
399 scf_transaction_destroy_children(handle->scf_trans); in ndmp_smf_end_transaction()
400 scf_transaction_destroy(handle->scf_trans); in ndmp_smf_end_transaction()
401 handle->scf_trans = NULL; in ndmp_smf_end_transaction()
410 ndmp_smf_delete_property(ndmp_scfhandle_t *handle, const char *propname) in ndmp_smf_delete_property() argument
418 if ((entry = scf_entry_create(handle->scf_handle)) != NULL) { in ndmp_smf_delete_property()
419 if (scf_transaction_property_delete(handle->scf_trans, entry, in ndmp_smf_delete_property()
442 ndmp_smf_set_property(ndmp_scfhandle_t *handle, const char *propname, in ndmp_smf_set_property() argument
457 if (((value = scf_value_create(handle->scf_handle)) == NULL) || in ndmp_smf_set_property()
458 ((entry = scf_entry_create(handle->scf_handle)) == NULL) || in ndmp_smf_set_property()
459 ((prop = scf_property_create(handle->scf_handle)) == NULL) || in ndmp_smf_set_property()
460 (scf_pg_get_property(handle->scf_pg, propname, prop) != 0) || in ndmp_smf_set_property()
467 if ((scf_transaction_property_change(handle->scf_trans, entry, propname, in ndmp_smf_set_property()
469 (scf_transaction_property_new(handle->scf_trans, entry, propname, in ndmp_smf_set_property()
521 ndmp_smf_get_property(ndmp_scfhandle_t *handle, const char *propname, in ndmp_smf_get_property() argument
532 if (((value = scf_value_create(handle->scf_handle)) != NULL) && in ndmp_smf_get_property()
533 ((prop = scf_property_create(handle->scf_handle)) != NULL) && in ndmp_smf_get_property()
534 (scf_pg_get_property(handle->scf_pg, propname, prop) == 0)) { in ndmp_smf_get_property()