1325 scf_simple_handle_t *ret;
1326
1327 ret = uu_zalloc(sizeof (*ret));
1328 if (ret == NULL) {
1329 (void) scf_set_error(SCF_ERROR_NO_MEMORY);
1330 return (NULL);
1331 } else {
1332
1333 ret->h = _scf_handle_create_and_bind(SCF_VERSION);
1334 ret->inst = scf_instance_create(ret->h);
1335 ret->snap = scf_snapshot_create(ret->h);
1336 ret->running_pg = scf_pg_create(ret->h);
1337 }
1338
1339 if ((ret->h == NULL) || (ret->inst == NULL) ||
1340 (ret->snap == NULL) || (ret->running_pg == NULL)) {
1341 goto out;
1342 }
1343
1344 if (scf_handle_decode_fmri(ret->h, fmri, NULL, NULL, ret->inst,
1345 NULL, NULL, NULL) == -1) {
1346 goto out;
1347 }
1348
1349 if ((scf_instance_get_snapshot(ret->inst, "running", ret->snap))
1350 != 0) {
1351 goto out;
1352 }
1353
1354 if (scf_instance_get_pg_composed(ret->inst, ret->snap, pg_name,
1355 ret->running_pg) != 0) {
1356 goto out;
1357 }
1358
1359 return (ret);
1360
1361 out:
1362 scf_simple_handle_destroy(ret);
1363 return (NULL);
1364 }
1365
|
1325 scf_simple_handle_t *ret;
1326
1327 ret = uu_zalloc(sizeof (*ret));
1328 if (ret == NULL) {
1329 (void) scf_set_error(SCF_ERROR_NO_MEMORY);
1330 return (NULL);
1331 } else {
1332
1333 ret->h = _scf_handle_create_and_bind(SCF_VERSION);
1334 ret->inst = scf_instance_create(ret->h);
1335 ret->snap = scf_snapshot_create(ret->h);
1336 ret->running_pg = scf_pg_create(ret->h);
1337 }
1338
1339 if ((ret->h == NULL) || (ret->inst == NULL) ||
1340 (ret->snap == NULL) || (ret->running_pg == NULL)) {
1341 goto out;
1342 }
1343
1344 if (scf_handle_decode_fmri(ret->h, fmri, NULL, NULL, ret->inst,
1345 NULL, NULL, 0) == -1) {
1346 goto out;
1347 }
1348
1349 if ((scf_instance_get_snapshot(ret->inst, "running", ret->snap))
1350 != 0) {
1351 goto out;
1352 }
1353
1354 if (scf_instance_get_pg_composed(ret->inst, ret->snap, pg_name,
1355 ret->running_pg) != 0) {
1356 goto out;
1357 }
1358
1359 return (ret);
1360
1361 out:
1362 scf_simple_handle_destroy(ret);
1363 return (NULL);
1364 }
1365
|