Lines Matching refs:handle

60  * sa_scf_fini(handle)
62 * Must be called when done. Called with the handle allocated in
68 sa_scf_fini(scfutilhandle_t *handle)
70 if (handle != NULL) {
72 if (handle->scope != NULL) {
74 scf_scope_destroy(handle->scope);
76 if (handle->instance != NULL)
77 scf_instance_destroy(handle->instance);
78 if (handle->service != NULL)
79 scf_service_destroy(handle->service);
80 if (handle->pg != NULL)
81 scf_pg_destroy(handle->pg);
82 if (handle->handle != NULL) {
83 handle->scf_state = SCH_STATE_UNINIT;
85 (void) scf_handle_unbind(handle->handle);
86 scf_handle_destroy(handle->handle);
88 free(handle);
102 scfutilhandle_t *handle;
108 handle = calloc(1, sizeof (scfutilhandle_t));
109 if (handle == NULL)
110 return (handle);
112 ihandle->scfhandle = handle;
113 handle->scf_state = SCH_STATE_INITIALIZING;
114 handle->handle = scf_handle_create(SCF_VERSION);
115 if (handle->handle == NULL) {
116 free(handle);
117 handle = NULL;
120 return (handle);
122 if (scf_handle_bind(handle->handle) != 0)
125 handle->scope = scf_scope_create(handle->handle);
126 handle->service = scf_service_create(handle->handle);
127 handle->pg = scf_pg_create(handle->handle);
130 handle->instance = scf_instance_create(handle->handle);
131 if (handle->scope == NULL || handle->service == NULL ||
132 handle->pg == NULL || handle->instance == NULL)
134 if (scf_handle_get_scope(handle->handle,
135 SCF_SCOPE_LOCAL, handle->scope) != 0)
137 if (scf_scope_get_service(handle->scope,
138 SA_GROUP_SVC_NAME, handle->service) != 0)
141 handle->scf_state = SCH_STATE_INIT;
142 if (sa_get_instance(handle, "default") != SA_OK) {
150 return (handle);
154 (void) sa_scf_fini(handle);
234 * sa_extract_pgroup(root, handle, pg, nodetype, proto, sectype)
241 sa_extract_pgroup(xmlNodePtr root, scfutilhandle_t *handle,
269 iter = scf_iter_create(handle->handle);
270 value = scf_value_create(handle->handle);
271 prop = scf_property_create(handle->handle);
328 * sa_extract_attrs(root, handle, instance)
337 sa_extract_attrs(xmlNodePtr root, scfutilhandle_t *handle,
346 prop = scf_property_create(handle->handle);
347 value = scf_value_create(handle->handle);
350 scf_instance_get_pg(instance, "operation", handle->pg) != 0) {
357 if (scf_pg_get_property(handle->pg, "state", prop) == 0) {
367 if (scf_pg_get_property(handle->pg, "zfs", prop) == 0) {
465 sa_share_from_pgroup(xmlNodePtr root, scfutilhandle_t *handle,
497 iter = scf_iter_create(handle->handle);
498 value = scf_value_create(handle->handle);
499 prop = scf_property_create(handle->handle);
568 * previous values may exist, handle
572 viter = scf_iter_create(handle->handle);
635 find_share_by_id(sa_handle_t handle, char *shareid)
642 for (group = sa_get_group(handle, NULL);
692 * sa_share_props_from_pgroup(root, handle, pg, id, sahandle)
701 sa_share_props_from_pgroup(xmlNodePtr root, scfutilhandle_t *handle,
812 iter = scf_iter_create(handle->handle);
813 value = scf_value_create(handle->handle);
814 prop = scf_property_create(handle->handle);
864 * sa_extract_group(root, handle, instance)
871 sa_extract_group(xmlNodePtr root, scfutilhandle_t *handle,
889 iter = scf_iter_create(handle->handle);
905 sa_extract_attrs(node, handle, instance);
922 while (scf_iter_next_pg(iter, handle->pg) > 0) {
924 ret = scf_pg_get_name(handle->pg, buff,
931 sa_share_from_pgroup(node, handle,
932 handle->pg, buff);
968 ret = sa_extract_pgroup(node, handle,
969 handle->pg, nodetype, proto,
972 err = scf_pg_delete(handle->pg);
996 ret = sa_extract_pgroup(node, handle,
997 handle->pg, "security", proto, sectype);
1023 while (scf_iter_next_pg(iter, handle->pg) > 0) {
1028 err = scf_pg_get_name(handle->pg, buff,
1034 handle, handle->pg, buff,
1049 * sa_extract_defaults(root, handle, instance)
1056 sa_extract_defaults(xmlNodePtr root, scfutilhandle_t *handle,
1066 prop = scf_property_create(handle->handle);
1067 value = scf_value_create(handle->handle);
1071 scf_instance_get_pg(instance, "operation", handle->pg) != 0)
1074 if (scf_pg_get_property(handle->pg, "legacy-timestamp", prop) != 0)
1101 * sa_get_config(handle, root, doc, sahandle)
1108 sa_get_config(scfutilhandle_t *handle, xmlNodePtr root, sa_handle_t sahandle)
1115 instance = scf_instance_create(handle->handle);
1116 iter = scf_iter_create(handle->handle);
1119 handle->service)) == 0) {
1126 handle, instance);
1127 ret = sa_extract_group(root, handle,
1143 * sa_get_instance(handle, instance)
1151 sa_get_instance(scfutilhandle_t *handle, char *instname)
1153 if (scf_service_get_instance(handle->service, instname,
1154 handle->instance) != 0) {
1161 * sa_create_instance(handle, instname)
1168 sa_create_instance(scfutilhandle_t *handle, char *instname)
1172 if (scf_service_add_instance(handle->service, instname,
1173 handle->instance) != 0) {
1189 * sa_delete_instance(handle, instname)
1195 sa_delete_instance(scfutilhandle_t *handle, char *instname)
1202 if ((ret = sa_get_instance(handle, instname)) == SA_OK) {
1203 if (scf_instance_delete(handle->instance) != 0)
1212 * sa_create_pgroup(handle, pgroup)
1218 sa_create_pgroup(scfutilhandle_t *handle, char *pgroup)
1224 * Only create a handle if it doesn't exist. It is ok to exist
1225 * since the pg handle will be set as a side effect.
1227 if (handle->pg == NULL)
1228 handle->pg = scf_pg_create(handle->handle);
1243 if (scf_instance_get_pg(handle->instance,
1244 pgroup, handle->pg) != 0) {
1247 if (scf_instance_add_pg(handle->instance, pgroup,
1248 SCF_GROUP_APPLICATION, persist, handle->pg) != 0) {
1263 * sa_delete_pgroup(handle, pgroup)
1270 sa_delete_pgroup(scfutilhandle_t *handle, char *pgroup)
1276 if (scf_instance_get_pg(handle->instance, pgroup, handle->pg) == 0) {
1278 if (scf_pg_delete(handle->pg) != 0)
1291 * sa_start_transaction(handle, pgroup)
1297 * Basic model is to hold the transaction in the handle and allow
1299 * transaction (or abort). There may eventually be a need to handle
1308 sa_start_transaction(scfutilhandle_t *handle, char *propgroup)
1315 if (handle == NULL)
1318 if (handle->scf_state == SCH_STATE_INIT) {
1319 ret = sa_create_pgroup(handle, propgroup);
1321 handle->trans = scf_transaction_create(handle->handle);
1322 if (handle->trans != NULL) {
1323 if (scf_transaction_start(handle->trans,
1324 handle->pg) != 0) {
1328 scf_transaction_destroy(handle->trans);
1329 handle->trans = NULL;
1348 * handle. Do all necessary cleanup.
1352 sa_end_transaction(scfutilhandle_t *handle, sa_handle_impl_t sahandle)
1356 if (handle == NULL || handle->trans == NULL || sahandle == NULL) {
1359 if (scf_transaction_commit(handle->trans) < 0)
1361 scf_transaction_destroy_children(handle->trans);
1362 scf_transaction_destroy(handle->trans);
1365 handle->trans = NULL;
1371 * sa_abort_transaction(handle)
1374 * handle. Do all necessary cleanup.
1378 sa_abort_transaction(scfutilhandle_t *handle)
1380 if (handle->trans != NULL) {
1381 scf_transaction_reset_all(handle->trans);
1382 scf_transaction_destroy_children(handle->trans);
1383 scf_transaction_destroy(handle->trans);
1384 handle->trans = NULL;
1432 * sa_set_property(handle, prop, value)
1438 sa_set_property(scfutilhandle_t *handle, char *propname, char *valstr)
1447 value = scf_value_create(handle->handle);
1448 entry = scf_entry_create(handle->handle);
1450 if (scf_transaction_property_change(handle->trans, entry,
1452 scf_transaction_property_new(handle->trans, entry,
1519 * sa_set_resource_property(handle, prop, value)
1526 sa_set_resource_property(scfutilhandle_t *handle, sa_share_t share)
1546 entry = scf_entry_create(handle->handle);
1550 if (scf_transaction_property_change(handle->trans, entry,
1552 scf_transaction_property_new(handle->trans, entry,
1561 value = scf_value_create(handle->handle);
1646 * sa_commit_share(handle, group, share)
1653 sa_commit_share(scfutilhandle_t *handle, sa_group_t group, sa_share_t share)
1688 ret = sa_get_instance(handle, groupname);
1716 ret = sa_create_pgroup(handle, sharename);
1723 ret = sa_start_transaction(handle, sharename);
1732 ret = sa_set_property(handle, "path",
1743 ret = sa_set_property(handle,
1755 ret = sa_set_property(handle,
1765 ret = sa_set_resource_property(handle, share);
1771 ret = sa_set_property(handle,
1783 ret = sa_end_transaction(handle,
1788 sa_abort_transaction(handle);
1810 * remove_resources(handle, share, shareid)
1816 remove_resources(scfutilhandle_t *handle, sa_share_t share, char *shareid)
1842 ret = sa_delete_pgroup(handle, propstring);
1853 * sa_delete_share(handle, group, share)
1859 sa_delete_share(scfutilhandle_t *handle, sa_group_t group, sa_share_t share)
1881 ret = sa_get_instance(handle, groupname);
1884 ret = remove_resources(handle, share, shareid);
1886 ret = sa_delete_pgroup(handle, shareid);
1896 ret = sa_delete_pgroup(handle,
1918 ret = sa_delete_pgroup(handle,