Lines Matching refs:handle

70 sa_scf_fini(scfutilhandle_t *handle)  in sa_scf_fini()  argument
72 if (handle != NULL) { in sa_scf_fini()
74 if (handle->scope != NULL) { in sa_scf_fini()
76 scf_scope_destroy(handle->scope); in sa_scf_fini()
78 if (handle->instance != NULL) in sa_scf_fini()
79 scf_instance_destroy(handle->instance); in sa_scf_fini()
80 if (handle->service != NULL) in sa_scf_fini()
81 scf_service_destroy(handle->service); in sa_scf_fini()
82 if (handle->pg != NULL) in sa_scf_fini()
83 scf_pg_destroy(handle->pg); in sa_scf_fini()
84 if (handle->handle != NULL) { in sa_scf_fini()
85 handle->scf_state = SCH_STATE_UNINIT; in sa_scf_fini()
87 (void) scf_handle_unbind(handle->handle); in sa_scf_fini()
88 scf_handle_destroy(handle->handle); in sa_scf_fini()
90 free(handle); in sa_scf_fini()
104 scfutilhandle_t *handle; in sa_scf_init() local
110 handle = calloc(1, sizeof (scfutilhandle_t)); in sa_scf_init()
111 if (handle == NULL) in sa_scf_init()
112 return (handle); in sa_scf_init()
114 ihandle->scfhandle = handle; in sa_scf_init()
115 handle->scf_state = SCH_STATE_INITIALIZING; in sa_scf_init()
116 handle->handle = scf_handle_create(SCF_VERSION); in sa_scf_init()
117 if (handle->handle == NULL) { in sa_scf_init()
118 free(handle); in sa_scf_init()
119 handle = NULL; in sa_scf_init()
122 return (handle); in sa_scf_init()
124 if (scf_handle_bind(handle->handle) != 0) in sa_scf_init()
127 handle->scope = scf_scope_create(handle->handle); in sa_scf_init()
128 handle->service = scf_service_create(handle->handle); in sa_scf_init()
129 handle->pg = scf_pg_create(handle->handle); in sa_scf_init()
132 handle->instance = scf_instance_create(handle->handle); in sa_scf_init()
133 if (handle->scope == NULL || handle->service == NULL || in sa_scf_init()
134 handle->pg == NULL || handle->instance == NULL) in sa_scf_init()
136 if (scf_handle_get_scope(handle->handle, in sa_scf_init()
137 SCF_SCOPE_LOCAL, handle->scope) != 0) in sa_scf_init()
139 if (scf_scope_get_service(handle->scope, in sa_scf_init()
140 SA_GROUP_SVC_NAME, handle->service) != 0) in sa_scf_init()
143 handle->scf_state = SCH_STATE_INIT; in sa_scf_init()
144 if (sa_get_instance(handle, "default") != SA_OK) { in sa_scf_init()
152 return (handle); in sa_scf_init()
156 (void) sa_scf_fini(handle); in sa_scf_init()
245 sa_extract_pgroup(xmlNodePtr root, scfutilhandle_t *handle, in sa_extract_pgroup() argument
272 iter = scf_iter_create(handle->handle); in sa_extract_pgroup()
273 value = scf_value_create(handle->handle); in sa_extract_pgroup()
274 prop = scf_property_create(handle->handle); in sa_extract_pgroup()
340 sa_extract_attrs(xmlNodePtr root, scfutilhandle_t *handle, in sa_extract_attrs() argument
349 prop = scf_property_create(handle->handle); in sa_extract_attrs()
350 value = scf_value_create(handle->handle); in sa_extract_attrs()
353 scf_instance_get_pg(instance, "operation", handle->pg) != 0) { in sa_extract_attrs()
360 if (scf_pg_get_property(handle->pg, "state", prop) == 0) { in sa_extract_attrs()
370 if (scf_pg_get_property(handle->pg, "zfs", prop) == 0) { in sa_extract_attrs()
468 sa_share_from_pgroup(xmlNodePtr root, scfutilhandle_t *handle, in sa_share_from_pgroup() argument
500 iter = scf_iter_create(handle->handle); in sa_share_from_pgroup()
501 value = scf_value_create(handle->handle); in sa_share_from_pgroup()
502 prop = scf_property_create(handle->handle); in sa_share_from_pgroup()
575 viter = scf_iter_create(handle->handle); in sa_share_from_pgroup()
638 find_share_by_id(sa_handle_t handle, char *shareid) in find_share_by_id() argument
645 for (group = sa_get_group(handle, NULL); in find_share_by_id()
704 sa_share_props_from_pgroup(xmlNodePtr root, scfutilhandle_t *handle, in sa_share_props_from_pgroup() argument
815 iter = scf_iter_create(handle->handle); in sa_share_props_from_pgroup()
816 value = scf_value_create(handle->handle); in sa_share_props_from_pgroup()
817 prop = scf_property_create(handle->handle); in sa_share_props_from_pgroup()
874 sa_extract_group(xmlNodePtr root, scfutilhandle_t *handle, in sa_extract_group() argument
892 iter = scf_iter_create(handle->handle); in sa_extract_group()
908 sa_extract_attrs(node, handle, instance); in sa_extract_group()
925 while (scf_iter_next_pg(iter, handle->pg) > 0) { in sa_extract_group()
927 ret = scf_pg_get_name(handle->pg, buff, in sa_extract_group()
934 sa_share_from_pgroup(node, handle, in sa_extract_group()
935 handle->pg, buff); in sa_extract_group()
971 ret = sa_extract_pgroup(node, handle, in sa_extract_group()
972 handle->pg, nodetype, proto, in sa_extract_group()
975 err = scf_pg_delete(handle->pg); in sa_extract_group()
999 ret = sa_extract_pgroup(node, handle, in sa_extract_group()
1000 handle->pg, "security", proto, sectype); in sa_extract_group()
1026 while (scf_iter_next_pg(iter, handle->pg) > 0) { in sa_extract_group()
1031 err = scf_pg_get_name(handle->pg, buff, in sa_extract_group()
1037 handle, handle->pg, buff, in sa_extract_group()
1059 sa_extract_defaults(xmlNodePtr root, scfutilhandle_t *handle, in sa_extract_defaults() argument
1069 prop = scf_property_create(handle->handle); in sa_extract_defaults()
1070 value = scf_value_create(handle->handle); in sa_extract_defaults()
1074 scf_instance_get_pg(instance, "operation", handle->pg) != 0) in sa_extract_defaults()
1077 if (scf_pg_get_property(handle->pg, "legacy-timestamp", prop) != 0) in sa_extract_defaults()
1111 sa_get_config(scfutilhandle_t *handle, xmlNodePtr root, sa_handle_t sahandle) in sa_get_config() argument
1118 instance = scf_instance_create(handle->handle); in sa_get_config()
1119 iter = scf_iter_create(handle->handle); in sa_get_config()
1122 handle->service)) == 0) { in sa_get_config()
1129 handle, instance); in sa_get_config()
1130 ret = sa_extract_group(root, handle, in sa_get_config()
1154 sa_get_instance(scfutilhandle_t *handle, char *instname) in sa_get_instance() argument
1156 if (scf_service_get_instance(handle->service, instname, in sa_get_instance()
1157 handle->instance) != 0) { in sa_get_instance()
1171 sa_create_instance(scfutilhandle_t *handle, char *instname) in sa_create_instance() argument
1175 if (scf_service_add_instance(handle->service, instname, in sa_create_instance()
1176 handle->instance) != 0) { in sa_create_instance()
1198 sa_delete_instance(scfutilhandle_t *handle, char *instname) in sa_delete_instance() argument
1205 if ((ret = sa_get_instance(handle, instname)) == SA_OK) { in sa_delete_instance()
1206 if (scf_instance_delete(handle->instance) != 0) in sa_delete_instance()
1221 sa_create_pgroup(scfutilhandle_t *handle, char *pgroup) in sa_create_pgroup() argument
1230 if (handle->pg == NULL) in sa_create_pgroup()
1231 handle->pg = scf_pg_create(handle->handle); in sa_create_pgroup()
1246 if (scf_instance_get_pg(handle->instance, in sa_create_pgroup()
1247 pgroup, handle->pg) != 0) { in sa_create_pgroup()
1250 if (scf_instance_add_pg(handle->instance, pgroup, in sa_create_pgroup()
1251 SCF_GROUP_APPLICATION, persist, handle->pg) != 0) { in sa_create_pgroup()
1273 sa_delete_pgroup(scfutilhandle_t *handle, char *pgroup) in sa_delete_pgroup() argument
1279 if (scf_instance_get_pg(handle->instance, pgroup, handle->pg) == 0) { in sa_delete_pgroup()
1281 if (scf_pg_delete(handle->pg) != 0) in sa_delete_pgroup()
1311 sa_start_transaction(scfutilhandle_t *handle, char *propgroup) in sa_start_transaction() argument
1318 if (handle == NULL) in sa_start_transaction()
1321 if (handle->scf_state == SCH_STATE_INIT) { in sa_start_transaction()
1322 ret = sa_create_pgroup(handle, propgroup); in sa_start_transaction()
1324 handle->trans = scf_transaction_create(handle->handle); in sa_start_transaction()
1325 if (handle->trans != NULL) { in sa_start_transaction()
1326 if (scf_transaction_start(handle->trans, in sa_start_transaction()
1327 handle->pg) != 0) { in sa_start_transaction()
1331 scf_transaction_destroy(handle->trans); in sa_start_transaction()
1332 handle->trans = NULL; in sa_start_transaction()
1355 sa_end_transaction(scfutilhandle_t *handle, sa_handle_impl_t sahandle) in sa_end_transaction() argument
1359 if (handle == NULL || handle->trans == NULL || sahandle == NULL) { in sa_end_transaction()
1362 if (scf_transaction_commit(handle->trans) < 0) in sa_end_transaction()
1364 scf_transaction_destroy_children(handle->trans); in sa_end_transaction()
1365 scf_transaction_destroy(handle->trans); in sa_end_transaction()
1368 handle->trans = NULL; in sa_end_transaction()
1381 sa_abort_transaction(scfutilhandle_t *handle) in sa_abort_transaction() argument
1383 if (handle->trans != NULL) { in sa_abort_transaction()
1384 scf_transaction_reset_all(handle->trans); in sa_abort_transaction()
1385 scf_transaction_destroy_children(handle->trans); in sa_abort_transaction()
1386 scf_transaction_destroy(handle->trans); in sa_abort_transaction()
1387 handle->trans = NULL; in sa_abort_transaction()
1441 sa_set_property(scfutilhandle_t *handle, char *propname, char *valstr) in sa_set_property() argument
1450 value = scf_value_create(handle->handle); in sa_set_property()
1451 entry = scf_entry_create(handle->handle); in sa_set_property()
1453 if (scf_transaction_property_change(handle->trans, entry, in sa_set_property()
1455 scf_transaction_property_new(handle->trans, entry, in sa_set_property()
1527 sa_set_resource_property(scfutilhandle_t *handle, sa_share_t share) in sa_set_resource_property() argument
1547 entry = scf_entry_create(handle->handle); in sa_set_resource_property()
1551 if (scf_transaction_property_change(handle->trans, entry, in sa_set_resource_property()
1553 scf_transaction_property_new(handle->trans, entry, in sa_set_resource_property()
1562 value = scf_value_create(handle->handle); in sa_set_resource_property()
1652 sa_commit_share(scfutilhandle_t *handle, sa_group_t group, sa_share_t share) in sa_commit_share() argument
1687 ret = sa_get_instance(handle, groupname); in sa_commit_share()
1715 ret = sa_create_pgroup(handle, sharename); in sa_commit_share()
1722 ret = sa_start_transaction(handle, sharename); in sa_commit_share()
1731 ret = sa_set_property(handle, "path", in sa_commit_share()
1742 ret = sa_set_property(handle, in sa_commit_share()
1754 ret = sa_set_property(handle, in sa_commit_share()
1764 ret = sa_set_resource_property(handle, share); in sa_commit_share()
1770 ret = sa_set_property(handle, in sa_commit_share()
1782 ret = sa_end_transaction(handle, in sa_commit_share()
1787 sa_abort_transaction(handle); in sa_commit_share()
1815 remove_resources(scfutilhandle_t *handle, sa_share_t share, char *shareid) in remove_resources() argument
1841 ret = sa_delete_pgroup(handle, propstring); in remove_resources()
1858 sa_delete_share(scfutilhandle_t *handle, sa_group_t group, sa_share_t share) in sa_delete_share() argument
1880 ret = sa_get_instance(handle, groupname); in sa_delete_share()
1883 ret = remove_resources(handle, share, shareid); in sa_delete_share()
1885 ret = sa_delete_pgroup(handle, shareid); in sa_delete_share()
1895 ret = sa_delete_pgroup(handle, in sa_delete_share()
1917 ret = sa_delete_pgroup(handle, in sa_delete_share()