Lines Matching refs:handle
68 sa_scf_fini(scfutilhandle_t *handle) in sa_scf_fini() argument
70 if (handle != NULL) { in sa_scf_fini()
72 if (handle->scope != NULL) { in sa_scf_fini()
74 scf_scope_destroy(handle->scope); in sa_scf_fini()
76 if (handle->instance != NULL) in sa_scf_fini()
77 scf_instance_destroy(handle->instance); in sa_scf_fini()
78 if (handle->service != NULL) in sa_scf_fini()
79 scf_service_destroy(handle->service); in sa_scf_fini()
80 if (handle->pg != NULL) in sa_scf_fini()
81 scf_pg_destroy(handle->pg); in sa_scf_fini()
82 if (handle->handle != NULL) { in sa_scf_fini()
83 handle->scf_state = SCH_STATE_UNINIT; in sa_scf_fini()
85 (void) scf_handle_unbind(handle->handle); in sa_scf_fini()
86 scf_handle_destroy(handle->handle); in sa_scf_fini()
88 free(handle); in sa_scf_fini()
102 scfutilhandle_t *handle; in sa_scf_init() local
108 handle = calloc(1, sizeof (scfutilhandle_t)); in sa_scf_init()
109 if (handle == NULL) in sa_scf_init()
110 return (handle); in sa_scf_init()
112 ihandle->scfhandle = handle; in sa_scf_init()
113 handle->scf_state = SCH_STATE_INITIALIZING; in sa_scf_init()
114 handle->handle = scf_handle_create(SCF_VERSION); in sa_scf_init()
115 if (handle->handle == NULL) { in sa_scf_init()
116 free(handle); in sa_scf_init()
117 handle = NULL; in sa_scf_init()
120 return (handle); in sa_scf_init()
122 if (scf_handle_bind(handle->handle) != 0) in sa_scf_init()
125 handle->scope = scf_scope_create(handle->handle); in sa_scf_init()
126 handle->service = scf_service_create(handle->handle); in sa_scf_init()
127 handle->pg = scf_pg_create(handle->handle); in sa_scf_init()
130 handle->instance = scf_instance_create(handle->handle); in sa_scf_init()
131 if (handle->scope == NULL || handle->service == NULL || in sa_scf_init()
132 handle->pg == NULL || handle->instance == NULL) in sa_scf_init()
134 if (scf_handle_get_scope(handle->handle, in sa_scf_init()
135 SCF_SCOPE_LOCAL, handle->scope) != 0) in sa_scf_init()
137 if (scf_scope_get_service(handle->scope, in sa_scf_init()
138 SA_GROUP_SVC_NAME, handle->service) != 0) in sa_scf_init()
141 handle->scf_state = SCH_STATE_INIT; in sa_scf_init()
142 if (sa_get_instance(handle, "default") != SA_OK) { in sa_scf_init()
150 return (handle); in sa_scf_init()
154 (void) sa_scf_fini(handle); in sa_scf_init()
241 sa_extract_pgroup(xmlNodePtr root, scfutilhandle_t *handle, in sa_extract_pgroup() argument
269 iter = scf_iter_create(handle->handle); in sa_extract_pgroup()
270 value = scf_value_create(handle->handle); in sa_extract_pgroup()
271 prop = scf_property_create(handle->handle); in sa_extract_pgroup()
337 sa_extract_attrs(xmlNodePtr root, scfutilhandle_t *handle, in sa_extract_attrs() argument
346 prop = scf_property_create(handle->handle); in sa_extract_attrs()
347 value = scf_value_create(handle->handle); in sa_extract_attrs()
350 scf_instance_get_pg(instance, "operation", handle->pg) != 0) { in sa_extract_attrs()
357 if (scf_pg_get_property(handle->pg, "state", prop) == 0) { in sa_extract_attrs()
367 if (scf_pg_get_property(handle->pg, "zfs", prop) == 0) { in sa_extract_attrs()
465 sa_share_from_pgroup(xmlNodePtr root, scfutilhandle_t *handle, in sa_share_from_pgroup() argument
497 iter = scf_iter_create(handle->handle); in sa_share_from_pgroup()
498 value = scf_value_create(handle->handle); in sa_share_from_pgroup()
499 prop = scf_property_create(handle->handle); in sa_share_from_pgroup()
572 viter = scf_iter_create(handle->handle); in sa_share_from_pgroup()
635 find_share_by_id(sa_handle_t handle, char *shareid) in find_share_by_id() argument
642 for (group = sa_get_group(handle, NULL); in find_share_by_id()
701 sa_share_props_from_pgroup(xmlNodePtr root, scfutilhandle_t *handle, in sa_share_props_from_pgroup() argument
812 iter = scf_iter_create(handle->handle); in sa_share_props_from_pgroup()
813 value = scf_value_create(handle->handle); in sa_share_props_from_pgroup()
814 prop = scf_property_create(handle->handle); in sa_share_props_from_pgroup()
871 sa_extract_group(xmlNodePtr root, scfutilhandle_t *handle, in sa_extract_group() argument
889 iter = scf_iter_create(handle->handle); in sa_extract_group()
905 sa_extract_attrs(node, handle, instance); in sa_extract_group()
922 while (scf_iter_next_pg(iter, handle->pg) > 0) { in sa_extract_group()
924 ret = scf_pg_get_name(handle->pg, buff, in sa_extract_group()
931 sa_share_from_pgroup(node, handle, in sa_extract_group()
932 handle->pg, buff); in sa_extract_group()
968 ret = sa_extract_pgroup(node, handle, in sa_extract_group()
969 handle->pg, nodetype, proto, in sa_extract_group()
972 err = scf_pg_delete(handle->pg); in sa_extract_group()
996 ret = sa_extract_pgroup(node, handle, in sa_extract_group()
997 handle->pg, "security", proto, sectype); in sa_extract_group()
1023 while (scf_iter_next_pg(iter, handle->pg) > 0) { in sa_extract_group()
1028 err = scf_pg_get_name(handle->pg, buff, in sa_extract_group()
1034 handle, handle->pg, buff, in sa_extract_group()
1056 sa_extract_defaults(xmlNodePtr root, scfutilhandle_t *handle, in sa_extract_defaults() argument
1066 prop = scf_property_create(handle->handle); in sa_extract_defaults()
1067 value = scf_value_create(handle->handle); in sa_extract_defaults()
1071 scf_instance_get_pg(instance, "operation", handle->pg) != 0) in sa_extract_defaults()
1074 if (scf_pg_get_property(handle->pg, "legacy-timestamp", prop) != 0) in sa_extract_defaults()
1108 sa_get_config(scfutilhandle_t *handle, xmlNodePtr root, sa_handle_t sahandle) in sa_get_config() argument
1115 instance = scf_instance_create(handle->handle); in sa_get_config()
1116 iter = scf_iter_create(handle->handle); in sa_get_config()
1119 handle->service)) == 0) { in sa_get_config()
1126 handle, instance); in sa_get_config()
1127 ret = sa_extract_group(root, handle, in sa_get_config()
1151 sa_get_instance(scfutilhandle_t *handle, char *instname) in sa_get_instance() argument
1153 if (scf_service_get_instance(handle->service, instname, in sa_get_instance()
1154 handle->instance) != 0) { in sa_get_instance()
1168 sa_create_instance(scfutilhandle_t *handle, char *instname) in sa_create_instance() argument
1172 if (scf_service_add_instance(handle->service, instname, in sa_create_instance()
1173 handle->instance) != 0) { in sa_create_instance()
1195 sa_delete_instance(scfutilhandle_t *handle, char *instname) in sa_delete_instance() argument
1202 if ((ret = sa_get_instance(handle, instname)) == SA_OK) { in sa_delete_instance()
1203 if (scf_instance_delete(handle->instance) != 0) in sa_delete_instance()
1218 sa_create_pgroup(scfutilhandle_t *handle, char *pgroup) in sa_create_pgroup() argument
1227 if (handle->pg == NULL) in sa_create_pgroup()
1228 handle->pg = scf_pg_create(handle->handle); in sa_create_pgroup()
1243 if (scf_instance_get_pg(handle->instance, in sa_create_pgroup()
1244 pgroup, handle->pg) != 0) { in sa_create_pgroup()
1247 if (scf_instance_add_pg(handle->instance, pgroup, in sa_create_pgroup()
1248 SCF_GROUP_APPLICATION, persist, handle->pg) != 0) { in sa_create_pgroup()
1270 sa_delete_pgroup(scfutilhandle_t *handle, char *pgroup) in sa_delete_pgroup() argument
1276 if (scf_instance_get_pg(handle->instance, pgroup, handle->pg) == 0) { in sa_delete_pgroup()
1278 if (scf_pg_delete(handle->pg) != 0) in sa_delete_pgroup()
1308 sa_start_transaction(scfutilhandle_t *handle, char *propgroup) in sa_start_transaction() argument
1315 if (handle == NULL) in sa_start_transaction()
1318 if (handle->scf_state == SCH_STATE_INIT) { in sa_start_transaction()
1319 ret = sa_create_pgroup(handle, propgroup); in sa_start_transaction()
1321 handle->trans = scf_transaction_create(handle->handle); in sa_start_transaction()
1322 if (handle->trans != NULL) { in sa_start_transaction()
1323 if (scf_transaction_start(handle->trans, in sa_start_transaction()
1324 handle->pg) != 0) { in sa_start_transaction()
1328 scf_transaction_destroy(handle->trans); in sa_start_transaction()
1329 handle->trans = NULL; in sa_start_transaction()
1352 sa_end_transaction(scfutilhandle_t *handle, sa_handle_impl_t sahandle) in sa_end_transaction() argument
1356 if (handle == NULL || handle->trans == NULL || sahandle == NULL) { in sa_end_transaction()
1359 if (scf_transaction_commit(handle->trans) < 0) in sa_end_transaction()
1361 scf_transaction_destroy_children(handle->trans); in sa_end_transaction()
1362 scf_transaction_destroy(handle->trans); in sa_end_transaction()
1365 handle->trans = NULL; in sa_end_transaction()
1378 sa_abort_transaction(scfutilhandle_t *handle) in sa_abort_transaction() argument
1380 if (handle->trans != NULL) { in sa_abort_transaction()
1381 scf_transaction_reset_all(handle->trans); in sa_abort_transaction()
1382 scf_transaction_destroy_children(handle->trans); in sa_abort_transaction()
1383 scf_transaction_destroy(handle->trans); in sa_abort_transaction()
1384 handle->trans = NULL; in sa_abort_transaction()
1438 sa_set_property(scfutilhandle_t *handle, char *propname, char *valstr) in sa_set_property() argument
1447 value = scf_value_create(handle->handle); in sa_set_property()
1448 entry = scf_entry_create(handle->handle); in sa_set_property()
1450 if (scf_transaction_property_change(handle->trans, entry, in sa_set_property()
1452 scf_transaction_property_new(handle->trans, entry, in sa_set_property()
1526 sa_set_resource_property(scfutilhandle_t *handle, sa_share_t share) in sa_set_resource_property() argument
1546 entry = scf_entry_create(handle->handle); in sa_set_resource_property()
1550 if (scf_transaction_property_change(handle->trans, entry, in sa_set_resource_property()
1552 scf_transaction_property_new(handle->trans, entry, in sa_set_resource_property()
1561 value = scf_value_create(handle->handle); in sa_set_resource_property()
1653 sa_commit_share(scfutilhandle_t *handle, sa_group_t group, sa_share_t share) in sa_commit_share() argument
1688 ret = sa_get_instance(handle, groupname); in sa_commit_share()
1716 ret = sa_create_pgroup(handle, sharename); in sa_commit_share()
1723 ret = sa_start_transaction(handle, sharename); in sa_commit_share()
1732 ret = sa_set_property(handle, "path", in sa_commit_share()
1743 ret = sa_set_property(handle, in sa_commit_share()
1755 ret = sa_set_property(handle, in sa_commit_share()
1765 ret = sa_set_resource_property(handle, share); in sa_commit_share()
1771 ret = sa_set_property(handle, in sa_commit_share()
1783 ret = sa_end_transaction(handle, in sa_commit_share()
1788 sa_abort_transaction(handle); in sa_commit_share()
1816 remove_resources(scfutilhandle_t *handle, sa_share_t share, char *shareid) in remove_resources() argument
1842 ret = sa_delete_pgroup(handle, propstring); in remove_resources()
1859 sa_delete_share(scfutilhandle_t *handle, sa_group_t group, sa_share_t share) in sa_delete_share() argument
1881 ret = sa_get_instance(handle, groupname); in sa_delete_share()
1884 ret = remove_resources(handle, share, shareid); in sa_delete_share()
1886 ret = sa_delete_pgroup(handle, shareid); in sa_delete_share()
1896 ret = sa_delete_pgroup(handle, in sa_delete_share()
1918 ret = sa_delete_pgroup(handle, in sa_delete_share()