Lines Matching defs:handle

67 /* NDMP scf handle structure */
112 ndmp_scfhandle_t *handle;
117 if ((handle = ndmp_smf_scf_init(NDMP_GROUP_FMRI_PREFIX)) == NULL) {
120 if (ndmp_smf_get_pg_name(handle, prop, &pgname)) {
121 ndmp_smf_scf_fini(handle);
125 if (ndmp_smf_create_service_pgroup(handle, pgname)) {
126 ndmp_smf_scf_fini(handle);
130 ndmp_smf_scf_fini(handle);
134 if (ndmp_smf_get_property(handle, prop, lval, NDMP_PROP_LEN) != 0) {
135 ndmp_smf_scf_fini(handle);
141 ndmp_smf_scf_fini(handle);
148 ndmp_scfhandle_t *handle;
152 if ((handle = ndmp_smf_scf_init(NDMP_GROUP_FMRI_PREFIX)) == NULL)
155 if (ndmp_smf_get_pg_name(handle, env, &pgname)) {
156 ndmp_smf_scf_fini(handle);
161 if (ndmp_smf_create_service_pgroup(handle, pgname)) {
162 ndmp_smf_scf_fini(handle);
166 if (ndmp_smf_start_transaction(handle)) {
167 ndmp_smf_scf_fini(handle);
172 rc = ndmp_smf_set_property(handle, env, env_val);
174 rc = ndmp_smf_delete_property(handle, env);
176 if (ndmp_config_saveenv(handle, (rc == 0)) == 0)
223 ndmp_config_saveenv(ndmp_scfhandle_t *handle, boolean_t commit)
227 ret = ndmp_smf_end_transaction(handle, commit);
229 ndmp_smf_scf_fini(handle);
234 * Must be called when done. Called with the handle allocated in
239 ndmp_smf_scf_fini(ndmp_scfhandle_t *handle)
241 if (handle == NULL)
244 scf_scope_destroy(handle->scf_scope);
245 scf_service_destroy(handle->scf_service);
246 scf_pg_destroy(handle->scf_pg);
247 handle->scf_state = NDMP_SCH_STATE_UNINIT;
248 (void) scf_handle_unbind(handle->scf_handle);
249 scf_handle_destroy(handle->scf_handle);
250 free(handle);
260 ndmp_scfhandle_t *handle;
262 handle = (ndmp_scfhandle_t *)calloc(1, sizeof (ndmp_scfhandle_t));
263 if (handle != NULL) {
264 handle->scf_state = NDMP_SCH_STATE_INITIALIZING;
265 if (((handle->scf_handle =
267 (scf_handle_bind(handle->scf_handle) == 0)) {
268 if ((handle->scf_scope =
269 scf_scope_create(handle->scf_handle)) == NULL)
272 if (scf_handle_get_local_scope(handle->scf_handle,
273 handle->scf_scope) != 0)
276 if ((handle->scf_service =
277 scf_service_create(handle->scf_handle)) == NULL)
280 if (scf_scope_get_service(handle->scf_scope, svc_name,
281 handle->scf_service) != SCF_SUCCESS)
284 if ((handle->scf_pg =
285 scf_pg_create(handle->scf_handle)) == NULL)
288 handle->scf_state = NDMP_SCH_STATE_INIT;
294 handle = NULL;
296 return (handle);
300 (void) ndmp_smf_scf_fini(handle);
309 ndmp_smf_create_service_pgroup(ndmp_scfhandle_t *handle, const char *pgroup)
314 * Only create a handle if it doesn't exist. It is ok to exist since
315 * the pg handle will be set as a side effect.
317 if (handle->scf_pg == NULL) {
318 if ((handle->scf_pg =
319 scf_pg_create(handle->scf_handle)) == NULL)
328 if (scf_service_get_pg(handle->scf_service,
329 pgroup, handle->scf_pg) != 0) {
331 if (scf_service_add_pg(handle->scf_service, pgroup,
332 SCF_GROUP_FRAMEWORK, 0, handle->scf_pg) != 0) {
348 * Start transaction on current pg in handle. The pg could be service or
349 * instance level. Must be called after pg handle is obtained from create or
353 ndmp_smf_start_transaction(ndmp_scfhandle_t *handle)
359 if (handle->scf_state == NDMP_SCH_STATE_INIT) {
360 if ((handle->scf_trans =
361 scf_transaction_create(handle->scf_handle)) != NULL) {
362 if (scf_transaction_start(handle->scf_trans,
363 handle->scf_pg) != 0) {
364 scf_transaction_destroy(handle->scf_trans);
365 handle->scf_trans = NULL;
383 * Commit the changes that were added to the transaction in the handle. Do all
387 ndmp_smf_end_transaction(ndmp_scfhandle_t *handle, boolean_t commit)
392 if (scf_transaction_commit(handle->scf_trans) < 0) {
398 scf_transaction_destroy_children(handle->scf_trans);
399 scf_transaction_destroy(handle->scf_trans);
400 handle->scf_trans = NULL;
409 ndmp_smf_delete_property(ndmp_scfhandle_t *handle, const char *propname)
417 if ((entry = scf_entry_create(handle->scf_handle)) != NULL) {
418 if (scf_transaction_property_delete(handle->scf_trans, entry,
441 ndmp_smf_set_property(ndmp_scfhandle_t *handle, const char *propname,
456 if (((value = scf_value_create(handle->scf_handle)) == NULL) ||
457 ((entry = scf_entry_create(handle->scf_handle)) == NULL) ||
458 ((prop = scf_property_create(handle->scf_handle)) == NULL) ||
459 (scf_pg_get_property(handle->scf_pg, propname, prop) != 0) ||
466 if ((scf_transaction_property_change(handle->scf_trans, entry, propname,
468 (scf_transaction_property_new(handle->scf_trans, entry, propname,
520 ndmp_smf_get_property(ndmp_scfhandle_t *handle, const char *propname,
531 if (((value = scf_value_create(handle->scf_handle)) != NULL) &&
532 ((prop = scf_property_create(handle->scf_handle)) != NULL) &&
533 (scf_pg_get_property(handle->scf_pg, propname, prop) == 0)) {