Lines Matching defs:h

32 #include "lowlevel_impl.h"
34 #include "repcache_protocol.h"
35 #include "scf_type.h"
37 #include <assert.h>
38 #include <alloca.h>
39 #include <door.h>
40 #include <errno.h>
41 #include <fcntl.h>
42 #include <fnmatch.h>
43 #include <libuutil.h>
44 #include <poll.h>
45 #include <pthread.h>
46 #include <synch.h>
47 #include <stddef.h>
48 #include <stdio.h>
49 #include <stdlib.h>
50 #include <string.h>
51 #include <sys/mman.h>
52 #include <sys/sysmacros.h>
53 #include <libzonecfg.h>
54 #include <unistd.h>
55 #include <dlfcn.h>
118 handle_hold_subhandles(scf_handle_t *h, int mask)
122 (void) pthread_mutex_lock(&h->rh_lock);
123 while (h->rh_hold_flags != 0 && h->rh_holder != pthread_self()) {
128 (void) pthread_cond_wait(&h->rh_cv, &h->rh_lock);
131 if (h->rh_hold_flags == 0)
132 h->rh_holder = pthread_self();
133 assert(!(h->rh_hold_flags & mask));
134 h->rh_hold_flags |= mask;
135 (void) pthread_mutex_unlock(&h->rh_lock);
139 handle_rele_subhandles(scf_handle_t *h, int mask)
143 (void) pthread_mutex_lock(&h->rh_lock);
144 assert(h->rh_holder == pthread_self());
145 assert((h->rh_hold_flags & mask));
147 h->rh_hold_flags &= ~mask;
148 if (h->rh_hold_flags == 0)
149 (void) pthread_cond_signal(&h->rh_cv);
150 (void) pthread_mutex_unlock(&h->rh_lock);
153 #define HOLD_HANDLE(h, flag, field) \
154 (handle_hold_subhandles((h), (flag)), (h)->field)
156 #define RELE_HANDLE(h, flag) \
157 (handle_rele_subhandles((h), (flag)))
163 #define HANDLE_HOLD_ITER(h) HOLD_HANDLE((h), RH_HOLD_ITER, rh_iter)
164 #define HANDLE_HOLD_SCOPE(h) HOLD_HANDLE((h), RH_HOLD_SCOPE, rh_scope)
165 #define HANDLE_HOLD_SERVICE(h) HOLD_HANDLE((h), RH_HOLD_SERVICE, rh_service)
166 #define HANDLE_HOLD_INSTANCE(h) HOLD_HANDLE((h), RH_HOLD_INSTANCE, rh_instance)
167 #define HANDLE_HOLD_SNAPSHOT(h) HOLD_HANDLE((h), RH_HOLD_SNAPSHOT, rh_snapshot)
168 #define HANDLE_HOLD_SNAPLVL(h) HOLD_HANDLE((h), RH_HOLD_SNAPLVL, rh_snaplvl)
169 #define HANDLE_HOLD_PG(h) HOLD_HANDLE((h), RH_HOLD_PG, rh_pg)
170 #define HANDLE_HOLD_PROPERTY(h) HOLD_HANDLE((h), RH_HOLD_PROPERTY, rh_property)
171 #define HANDLE_HOLD_VALUE(h) HOLD_HANDLE((h), RH_HOLD_VALUE, rh_value)
173 #define HANDLE_RELE_ITER(h) RELE_HANDLE((h), RH_HOLD_ITER)
174 #define HANDLE_RELE_SCOPE(h) RELE_HANDLE((h), RH_HOLD_SCOPE)
175 #define HANDLE_RELE_SERVICE(h) RELE_HANDLE((h), RH_HOLD_SERVICE)
176 #define HANDLE_RELE_INSTANCE(h) RELE_HANDLE((h), RH_HOLD_INSTANCE)
177 #define HANDLE_RELE_SNAPSHOT(h) RELE_HANDLE((h), RH_HOLD_SNAPSHOT)
178 #define HANDLE_RELE_SNAPLVL(h) RELE_HANDLE((h), RH_HOLD_SNAPLVL)
179 #define HANDLE_RELE_PG(h) RELE_HANDLE((h), RH_HOLD_PG)
180 #define HANDLE_RELE_PROPERTY(h) RELE_HANDLE((h), RH_HOLD_PROPERTY)
181 #define HANDLE_RELE_VALUE(h) RELE_HANDLE((h), RH_HOLD_VALUE)
515 handle_do_close(scf_handle_t *h)
517 assert(MUTEX_HELD(&h->rh_lock));
518 assert(h->rh_doorfd != -1);
524 if (h->rh_fd_users > 0) {
525 h->rh_doorfd_old = h->rh_doorfd;
526 h->rh_doorfd = -1;
528 assert(h->rh_doorfd_old == -1);
529 (void) close(h->rh_doorfd);
530 h->rh_doorfd = -1;
539 handle_is_bound(scf_handle_t *h)
541 assert(MUTEX_HELD(&h->rh_lock));
543 if (h->rh_doorfd == -1)
546 if (getpid() == h->rh_doorpid)
550 handle_do_close(h);
555 handle_has_server_locked(scf_handle_t *h)
558 assert(MUTEX_HELD(&h->rh_lock));
560 return (handle_is_bound(h) && door_info(h->rh_doorfd, &i) != -1 &&
565 handle_has_server(scf_handle_t *h)
569 (void) pthread_mutex_lock(&h->rh_lock);
570 ret = handle_has_server_locked(h);
571 (void) pthread_mutex_unlock(&h->rh_lock);
577 * This makes a door request on the client door associated with handle h.
578 * It will automatically retry calls which fail on EINTR. If h is not bound,
585 make_door_call(scf_handle_t *h, const void *req, size_t req_sz,
591 assert(MUTEX_HELD(&h->rh_lock));
593 if (!handle_is_bound(h)) {
604 while ((r = door_call(h->rh_doorfd, &arg)) < 0) {
818 scf_handle_t *h;
820 h = scf_handle_create(ver);
821 if (h == NULL)
824 if (scf_handle_bind(h) == -1) {
825 scf_handle_destroy(h);
828 return (h);
1031 scf_handle_t *h = dp->rd_handle;
1037 assert(MUTEX_HELD(&h->rh_lock));
1041 if (h->rh_flags & HANDLE_DEAD)
1044 if (!handle_is_bound(h))
1051 r = make_door_call(h, &request, sizeof (request),
1075 scf_handle_t *h = iter->iter_handle;
1080 assert(MUTEX_HELD(&h->rh_lock));
1082 if (h->rh_flags & HANDLE_DEAD)
1085 if (!handle_is_bound(h))
1091 r = make_door_call(h, &request, sizeof (request),
1269 handle_get(scf_handle_t *h)
1271 (void) pthread_mutex_lock(&h->rh_lock);
1272 if (h->rh_flags & HANDLE_DEAD) {
1273 (void) pthread_mutex_unlock(&h->rh_lock);
1277 (void) pthread_mutex_unlock(&h->rh_lock);
1278 return (h);
1408 scf_myname(scf_handle_t *h, char *out, size_t len)
1412 if (!handle_has_server(h))
1423 handle_alloc_entityid(scf_handle_t *h)
1427 assert(MUTEX_HELD(&h->rh_lock));
1429 if (uu_list_numnodes(h->rh_dataels) == UINT32_MAX)
1438 nextid = h->rh_nextentity + 1;
1444 h->rh_flags |= HANDLE_WRAPPED_ENTITY;
1446 if (!(h->rh_flags & HANDLE_WRAPPED_ENTITY))
1449 cur = uu_list_find(h->rh_dataels, NULL, &nextid, NULL);
1453 if (nextid == h->rh_nextentity)
1458 h->rh_nextentity = nextid;
1463 handle_alloc_iterid(scf_handle_t *h)
1467 assert(MUTEX_HELD(&h->rh_lock));
1469 if (uu_list_numnodes(h->rh_iters) == UINT32_MAX)
1473 nextid = h->rh_nextiter + 1;
1479 h->rh_flags |= HANDLE_WRAPPED_ITER;
1481 if (!(h->rh_flags & HANDLE_WRAPPED_ITER))
1484 cur = uu_list_find(h->rh_iters, NULL, &nextid, NULL);
1488 if (nextid == h->rh_nextiter)
1493 h->rh_nextiter = nextid;
1512 * _INVALID_ARGUMENT - h is NULL
1519 datael_init(scf_datael_t *dp, scf_handle_t *h, uint32_t type)
1523 if (h == NULL)
1528 dp->rd_handle = h;
1532 (void) pthread_mutex_lock(&h->rh_lock);
1533 if (h->rh_flags & HANDLE_DEAD) {
1539 (void) pthread_mutex_unlock(&h->rh_lock);
1542 dp->rd_entity = handle_alloc_entityid(h);
1544 (void) pthread_mutex_unlock(&h->rh_lock);
1551 (void) uu_list_insert_before(h->rh_dataels, NULL, dp);
1552 h->rh_extrefs++;
1556 (void) pthread_mutex_unlock(&h->rh_lock);
1564 scf_handle_t *h = dp->rd_handle;
1569 (void) pthread_mutex_lock(&h->rh_lock);
1570 uu_list_remove(h->rh_dataels, dp);
1571 --h->rh_extrefs;
1573 if (handle_is_bound(h)) {
1577 (void) make_door_call(h, &request, sizeof (request),
1580 handle_unrefed(h); /* drops h->rh_lock */
1598 scf_handle_t *h = dp->rd_handle;
1603 assert(MUTEX_HELD(&h->rh_lock));
1608 (void) make_door_call(h, &request, sizeof (request),
1624 scf_handle_t *h = dp->rd_handle;
1626 (void) pthread_mutex_lock(&h->rh_lock);
1628 (void) pthread_mutex_unlock(&h->rh_lock);
1649 scf_handle_t *h = dp->rd_handle;
1655 (void) pthread_mutex_lock(&h->rh_lock);
1661 r = make_door_call(h, &request, sizeof (request),
1663 (void) pthread_mutex_unlock(&h->rh_lock);
1686 scf_handle_t *h = dp->rd_handle;
1693 if (h != pp->rd_handle)
1696 (void) pthread_mutex_lock(&h->rh_lock);
1703 r = make_door_call(h, &request, sizeof (request),
1705 (void) pthread_mutex_unlock(&h->rh_lock);
1735 scf_handle_t *h = dp->rd_handle;
1738 if (h != out->rd_handle)
1744 assert(MUTEX_HELD(&h->rh_lock));
1768 r = make_door_call(h, &request, sizeof (request),
1784 r = make_door_call(h, &read_request, sizeof (read_request),
1819 scf_handle_t *h = dp->rd_handle;
1822 if (h != out->rd_handle)
1828 assert(MUTEX_HELD(&h->rh_lock));
1842 r = make_door_call(h, &request, sizeof (request),
1865 scf_handle_t *h = dp->rd_handle;
1872 iter = HANDLE_HOLD_ITER(h);
1877 out = &HANDLE_HOLD_SERVICE(h)->rd_d;
1882 out = &HANDLE_HOLD_INSTANCE(h)->rd_d;
1887 out = &HANDLE_HOLD_SNAPSHOT(h)->rd_d;
1892 out = &HANDLE_HOLD_SNAPLVL(h)->rd_d;
1897 out = &HANDLE_HOLD_PG(h)->rd_d;
1902 out = &HANDLE_HOLD_PROPERTY(h)->rd_d;
1912 (void) pthread_mutex_lock(&h->rh_lock);
1918 (void) pthread_mutex_unlock(&h->rh_lock);
1921 HANDLE_RELE_ITER(h);
1924 handle_rele_subhandles(h, held);
1957 scf_handle_t *h = dp->rd_handle;
1967 cp = &HANDLE_HOLD_SCOPE(h)->rd_d;
1971 cp = &HANDLE_HOLD_SERVICE(h)->rd_d;
1975 cp = &HANDLE_HOLD_INSTANCE(h)->rd_d;
1983 assert(h == cp->rd_handle);
1985 } else if (h != cp->rd_handle) {
1995 (void) pthread_mutex_lock(&h->rh_lock);
2002 request.rpr_changeid = handle_next_changeid(h);
2003 r = make_door_call(h, &request, sizeof (request),
2005 (void) pthread_mutex_unlock(&h->rh_lock);
2008 handle_rele_subhandles(h, held);
2020 handle_rele_subhandles(h, held);
2028 scf_handle_t *h = dp->rd_handle;
2038 cp = &HANDLE_HOLD_PG(h)->rd_d;
2039 assert(h == cp->rd_handle);
2041 } else if (h != cp->rd_handle) {
2059 (void) pthread_mutex_lock(&h->rh_lock);
2066 request.rpr_changeid = handle_next_changeid(h);
2067 r = make_door_call(h, &request, sizeof (request),
2069 (void) pthread_mutex_unlock(&h->rh_lock);
2072 HANDLE_RELE_PG(h);
2084 HANDLE_RELE_PG(h);
2091 scf_handle_t *h = dp->rd_handle;
2097 (void) pthread_mutex_lock(&h->rh_lock);
2102 request.rpr_changeid = handle_next_changeid(h);
2103 r = make_door_call(h, &request, sizeof (request),
2105 (void) pthread_mutex_unlock(&h->rh_lock);
2118 * _INVALID_ARGUMENT - h is NULL
2120 * _HANDLE_DESTROYED - h has been destroyed
2126 scf_iter_create(scf_handle_t *h)
2130 if (h == NULL) {
2142 iter->iter_handle = h;
2146 (void) pthread_mutex_lock(&h->rh_lock);
2147 iter->iter_id = handle_alloc_iterid(h);
2149 (void) pthread_mutex_unlock(&h->rh_lock);
2157 (void) pthread_mutex_unlock(&h->rh_lock);
2161 (void) uu_list_insert_before(h->rh_iters, NULL, iter);
2162 h->rh_extrefs++;
2163 (void) pthread_mutex_unlock(&h->rh_lock);
2221 handle_unrefed(handle); /* drops h->rh_lock */
2260 scf_handle_t *h = iter->iter_handle;
2261 if (h != handle)
2264 (void) pthread_mutex_lock(&h->rh_lock);
2267 if (!handle_is_bound(h)) {
2268 (void) pthread_mutex_unlock(&h->rh_lock);
2272 if (!handle_has_server_locked(h)) {
2273 (void) pthread_mutex_unlock(&h->rh_lock);
2279 (void) pthread_mutex_unlock(&h->rh_lock);
2287 scf_handle_t *h = iter->iter_handle;
2289 if (h != out->rd_d.rd_handle)
2292 (void) pthread_mutex_lock(&h->rh_lock);
2294 (void) pthread_mutex_unlock(&h->rh_lock);
2298 (void) pthread_mutex_unlock(&h->rh_lock);
2302 if ((ret = handle_get_local_scope_locked(h, out)) ==
2311 (void) pthread_mutex_unlock(&h->rh_lock);
2316 scf_handle_get_scope(scf_handle_t *h, const char *name, scf_scope_t *out)
2320 if (h != out->rd_d.rd_handle)
2323 (void) pthread_mutex_lock(&h->rh_lock);
2325 ret = handle_get_local_scope_locked(h, out);
2333 (void) pthread_mutex_unlock(&h->rh_lock);
2341 scf_handle_t *h = dp->rd_handle;
2348 if (h != iter->iter_handle)
2351 (void) pthread_mutex_lock(&h->rh_lock);
2364 r = make_door_call(h, &request, sizeof (request),
2368 (void) pthread_mutex_unlock(&h->rh_lock);
2372 (void) pthread_mutex_unlock(&h->rh_lock);
2376 (void) pthread_mutex_unlock(&h->rh_lock);
2384 scf_handle_t *h = dp->rd_handle;
2391 if (h != iter->iter_handle)
2400 (void) pthread_mutex_lock(&h->rh_lock);
2412 r = make_door_call(h, &request, sizeof (request),
2416 (void) pthread_mutex_unlock(&h->rh_lock);
2421 (void) pthread_mutex_unlock(&h->rh_lock);
2425 (void) pthread_mutex_unlock(&h->rh_lock);
2432 scf_handle_t *h = iter->iter_handle;
2438 if (h != out->rd_handle)
2441 (void) pthread_mutex_lock(&h->rh_lock);
2444 (void) pthread_mutex_unlock(&h->rh_lock);
2449 (void) pthread_mutex_unlock(&h->rh_lock);
2459 r = make_door_call(h, &request, sizeof (request),
2463 (void) pthread_mutex_unlock(&h->rh_lock);
2468 (void) pthread_mutex_unlock(&h->rh_lock);
2472 (void) pthread_mutex_unlock(&h->rh_lock);
2476 (void) pthread_mutex_unlock(&h->rh_lock);
3060 scf_handle_t *h = src->rd_handle;
3067 if (h != dst->rd_d.rd_handle)
3072 dst = HANDLE_HOLD_SNAPLVL(h);
3074 (void) pthread_mutex_lock(&h->rh_lock);
3081 r = make_door_call(h, &request, sizeof (request),
3096 (void) pthread_mutex_unlock(&h->rh_lock);
3099 HANDLE_RELE_SNAPLVL(h);
3196 scf_handle_t *h = dp->rd_handle;
3203 (void) pthread_mutex_lock(&h->rh_lock);
3208 request.rpr_changeid = handle_next_changeid(h);
3210 r = make_door_call(h, &request, sizeof (request),
3212 (void) pthread_mutex_unlock(&h->rh_lock);
3248 scf_handle_t *h = pg->rd_d.rd_handle;
3257 (void) pthread_mutex_lock(&h->rh_lock);
3262 if (!handle_is_bound(h)) {
3263 (void) pthread_mutex_unlock(&h->rh_lock);
3266 r = make_door_call_retfd(h->rh_doorfd, &request, sizeof (request),
3268 (void) pthread_mutex_unlock(&h->rh_lock);
3292 scf_notify_add_pattern(scf_handle_t *h, int type, const char *name)
3298 (void) pthread_mutex_lock(&h->rh_lock);
3303 r = make_door_call(h, &request, sizeof (request),
3305 (void) pthread_mutex_unlock(&h->rh_lock);
3317 _scf_notify_add_pgname(scf_handle_t *h, const char *name)
3319 return (scf_notify_add_pattern(h, REP_PROTOCOL_NOTIFY_PGNAME, name));
3323 _scf_notify_add_pgtype(scf_handle_t *h, const char *type)
3325 return (scf_notify_add_pattern(h, REP_PROTOCOL_NOTIFY_PGTYPE, type));
3334 scf_handle_t *h = pg->rd_d.rd_handle;
3339 (void) pthread_mutex_lock(&h->rh_lock);
3341 if (!handle_is_bound(h)) {
3342 (void) pthread_mutex_unlock(&h->rh_lock);
3345 fd = h->rh_doorfd;
3346 ++h->rh_fd_users;
3347 assert(h->rh_fd_users > 0);
3351 (void) pthread_mutex_unlock(&h->rh_lock);
3356 (void) pthread_mutex_lock(&h->rh_lock);
3357 assert(h->rh_fd_users > 0);
3358 if (--h->rh_fd_users == 0) {
3359 (void) pthread_cond_broadcast(&h->rh_cv);
3364 if (h->rh_doorfd_old != -1) {
3365 assert(h->rh_doorfd == -1);
3366 assert(fd == h->rh_doorfd_old);
3367 (void) close(h->rh_doorfd_old);
3368 h->rh_doorfd_old = -1;
3371 handle_unrefed(h); /* drops h->rh_lock */
3390 scf_handle_t *h = inst->rd_d.rd_handle;
3397 if (h != snap->rd_d.rd_handle)
3404 (void) pthread_mutex_lock(&h->rh_lock);
3413 r = make_door_call(h, &request, sizeof (request),
3415 (void) pthread_mutex_unlock(&h->rh_lock);
3431 scf_handle_t *h = inst->rd_d.rd_handle;
3438 if (h != snap->rd_d.rd_handle)
3453 (void) pthread_mutex_lock(&h->rh_lock);
3461 r = make_door_call(h, &request, sizeof (request),
3463 (void) pthread_mutex_unlock(&h->rh_lock);
3493 scf_handle_t *h = dest->rd_d.rd_handle;
3500 if (h != src->rd_d.rd_handle)
3503 (void) pthread_mutex_lock(&h->rh_lock);
3511 r = make_door_call(h, &request, sizeof (request),
3513 (void) pthread_mutex_unlock(&h->rh_lock);
3566 scf_handle_t *h = prop->rd_d.rd_handle;
3573 assert(MUTEX_HELD(&h->rh_lock));
3579 r = make_door_call(h, &request, sizeof (request),
3596 scf_handle_t *h = prop->rd_d.rd_handle;
3600 (void) pthread_mutex_lock(&h->rh_lock);
3602 (void) pthread_mutex_unlock(&h->rh_lock);
3613 scf_handle_t *h = prop->rd_d.rd_handle;
3621 (void) pthread_mutex_lock(&h->rh_lock);
3623 (void) pthread_mutex_unlock(&h->rh_lock);
3698 scf_handle_t *h = tran->tran_pg.rd_d.rd_handle;
3704 if (h != pg->rd_d.rd_handle)
3707 (void) pthread_mutex_lock(&h->rh_lock);
3709 (void) pthread_mutex_unlock(&h->rh_lock);
3719 r = make_door_call(h, &request, sizeof (request),
3723 (void) pthread_mutex_unlock(&h->rh_lock);
3731 (void) pthread_mutex_unlock(&h->rh_lock);
3737 (void) pthread_mutex_unlock(&h->rh_lock);
3747 scf_handle_t *h = cur->entry_handle;
3749 assert(MUTEX_HELD(&h->rh_lock));
3776 scf_handle_t *h = entry->entry_handle;
3778 assert(MUTEX_HELD(&h->rh_lock));
3783 assert(h->rh_entries > 0);
3784 --h->rh_entries;
3785 --h->rh_extrefs;
3800 scf_handle_t *h = tran->tran_pg.rd_d.rd_handle;
3808 if (h != entry->entry_handle)
3816 prop_p = HANDLE_HOLD_PROPERTY(h);
3818 (void) pthread_mutex_lock(&h->rh_lock);
3889 (void) pthread_mutex_unlock(&h->rh_lock);
3891 HANDLE_RELE_PROPERTY(h);
3896 (void) pthread_mutex_unlock(&h->rh_lock);
3898 HANDLE_RELE_PROPERTY(h);
4039 scf_handle_t *h = tran->tran_pg.rd_d.rd_handle;
4050 (void) pthread_mutex_lock(&h->rh_lock);
4053 (void) pthread_mutex_unlock(&h->rh_lock);
4062 (void) pthread_mutex_unlock(&h->rh_lock);
4084 (void) pthread_mutex_unlock(&h->rh_lock);
4092 r = make_door_call(h, request, request_size,
4096 (void) pthread_mutex_unlock(&h->rh_lock);
4102 (void) pthread_mutex_unlock(&h->rh_lock);
4107 (void) pthread_mutex_unlock(&h->rh_lock);
4179 scf_entry_create(scf_handle_t *h)
4183 if (h == NULL) {
4194 ret->entry_handle = h;
4196 (void) pthread_mutex_lock(&h->rh_lock);
4197 if (h->rh_flags & HANDLE_DEAD) {
4198 (void) pthread_mutex_unlock(&h->rh_lock);
4203 h->rh_entries++;
4204 h->rh_extrefs++;
4205 (void) pthread_mutex_unlock(&h->rh_lock);
4221 scf_handle_t *h = entry->entry_handle;
4223 (void) pthread_mutex_lock(&h->rh_lock);
4225 (void) pthread_mutex_unlock(&h->rh_lock);
4231 scf_handle_t *h = entry->entry_handle;
4233 (void) pthread_mutex_lock(&h->rh_lock);
4235 handle_unrefed(h); /* drops h->rh_lock */
4241 scf_handle_t *h;
4246 h = entry->entry_handle;
4248 (void) pthread_mutex_lock(&h->rh_lock);
4250 handle_unrefed(h); /* drops h->rh_lock */
4267 scf_handle_t *h = entry->entry_handle;
4269 if (h != v->value_handle)
4272 (void) pthread_mutex_lock(&h->rh_lock);
4275 (void) pthread_mutex_unlock(&h->rh_lock);
4280 (void) pthread_mutex_unlock(&h->rh_lock);
4285 (void) pthread_mutex_unlock(&h->rh_lock);
4290 (void) pthread_mutex_unlock(&h->rh_lock);
4295 (void) pthread_mutex_unlock(&h->rh_lock);
4301 (void) pthread_mutex_unlock(&h->rh_lock);
4306 (void) pthread_mutex_unlock(&h->rh_lock);
4320 (void) pthread_mutex_unlock(&h->rh_lock);
4329 scf_value_create(scf_handle_t *h)
4333 if (h == NULL) {
4341 ret->value_handle = h;
4342 (void) pthread_mutex_lock(&h->rh_lock);
4343 if (h->rh_flags & HANDLE_DEAD) {
4344 (void) pthread_mutex_unlock(&h->rh_lock);
4349 h->rh_values++;
4350 h->rh_extrefs++;
4351 (void) pthread_mutex_unlock(&h->rh_lock);
4365 scf_handle_t *h = val->value_handle;
4366 assert(MUTEX_HELD(&h->rh_lock));
4387 assert(h->rh_values > 0);
4388 --h->rh_values;
4389 --h->rh_extrefs;
4397 scf_handle_t *h = val->value_handle;
4399 (void) pthread_mutex_lock(&h->rh_lock);
4401 (void) pthread_mutex_unlock(&h->rh_lock);
4413 scf_handle_t *h;
4418 h = val->value_handle;
4420 (void) pthread_mutex_lock(&h->rh_lock);
4422 handle_unrefed(h); /* drops h->rh_lock */
4429 scf_handle_t *h = val->value_handle;
4431 (void) pthread_mutex_lock(&h->rh_lock);
4433 (void) pthread_mutex_unlock(&h->rh_lock);
4449 scf_handle_t *h = val->value_handle;
4451 (void) pthread_mutex_lock(&h->rh_lock);
4453 (void) pthread_mutex_unlock(&h->rh_lock);
4463 scf_handle_t *h = val->value_handle;
4465 (void) pthread_mutex_lock(&h->rh_lock);
4467 (void) pthread_mutex_unlock(&h->rh_lock);
4507 scf_handle_t *h = val->value_handle;
4510 (void) pthread_mutex_lock(&h->rh_lock);
4512 (void) pthread_mutex_unlock(&h->rh_lock);
4520 (void) pthread_mutex_unlock(&h->rh_lock);
4529 scf_handle_t *h = val->value_handle;
4532 (void) pthread_mutex_lock(&h->rh_lock);
4534 (void) pthread_mutex_unlock(&h->rh_lock);
4539 (void) pthread_mutex_unlock(&h->rh_lock);
4548 scf_handle_t *h = val->value_handle;
4551 (void) pthread_mutex_lock(&h->rh_lock);
4553 (void) pthread_mutex_unlock(&h->rh_lock);
4558 (void) pthread_mutex_unlock(&h->rh_lock);
4567 scf_handle_t *h = val->value_handle;
4572 (void) pthread_mutex_lock(&h->rh_lock);
4574 (void) pthread_mutex_unlock(&h->rh_lock);
4583 (void) pthread_mutex_unlock(&h->rh_lock);
4601 scf_handle_t *h = val->value_handle;
4603 (void) pthread_mutex_lock(&h->rh_lock);
4605 (void) pthread_mutex_unlock(&h->rh_lock);
4609 (void) pthread_mutex_unlock(&h->rh_lock);
4617 scf_handle_t *h = val->value_handle;
4619 (void) pthread_mutex_lock(&h->rh_lock);
4621 (void) pthread_mutex_unlock(&h->rh_lock);
4625 (void) pthread_mutex_unlock(&h->rh_lock);
4633 scf_handle_t *h = v->value_handle;
4635 (void) pthread_mutex_lock(&h->rh_lock);
4637 (void) pthread_mutex_unlock(&h->rh_lock);
4645 (void) pthread_mutex_unlock(&h->rh_lock);
4652 scf_handle_t *h = v->value_handle;
4654 (void) pthread_mutex_lock(&h->rh_lock);
4658 (void) pthread_mutex_unlock(&h->rh_lock);
4664 scf_handle_t *h = v->value_handle;
4666 (void) pthread_mutex_lock(&h->rh_lock);
4670 (void) pthread_mutex_unlock(&h->rh_lock);
4676 scf_handle_t *h = v->value_handle;
4678 (void) pthread_mutex_lock(&h->rh_lock);
4682 (void) pthread_mutex_unlock(&h->rh_lock);
4688 scf_handle_t *h = v->value_handle;
4690 (void) pthread_mutex_lock(&h->rh_lock);
4693 (void) pthread_mutex_unlock(&h->rh_lock);
4702 (void) pthread_mutex_unlock(&h->rh_lock);
4709 scf_handle_t *h = v->value_handle;
4711 (void) pthread_mutex_lock(&h->rh_lock);
4714 (void) pthread_mutex_unlock(&h->rh_lock);
4719 (void) pthread_mutex_unlock(&h->rh_lock);
4723 (void) pthread_mutex_unlock(&h->rh_lock);
4730 scf_handle_t *h = v->value_handle;
4732 (void) pthread_mutex_lock(&h->rh_lock);
4735 (void) pthread_mutex_unlock(&h->rh_lock);
4740 (void) pthread_mutex_unlock(&h->rh_lock);
4744 (void) pthread_mutex_unlock(&h->rh_lock);
4751 scf_handle_t *h = v->value_handle;
4753 (void) pthread_mutex_lock(&h->rh_lock);
4756 (void) pthread_mutex_unlock(&h->rh_lock);
4762 (void) pthread_mutex_unlock(&h->rh_lock);
4778 scf_handle_t *h = v_arg->value_handle;
4784 (void) pthread_mutex_lock(&h->rh_lock);
4786 (void) pthread_mutex_unlock(&h->rh_lock);
4791 h->rh_values++; /* keep the handle from going away */
4792 h->rh_extrefs++;
4793 (void) pthread_mutex_unlock(&h->rh_lock);
4832 (void) pthread_mutex_lock(&h->rh_lock);
4833 h->rh_values--;
4834 h->rh_extrefs--;
4835 handle_unrefed(h);
4861 scf_handle_t *h = v->value_handle;
4952 (void) pthread_mutex_lock(&h->rh_lock);
4958 (void) pthread_mutex_lock(&h->rh_lock);
4965 (void) pthread_mutex_lock(&h->rh_lock);
4970 (void) pthread_mutex_unlock(&h->rh_lock);
4993 scf_handle_t *h = iter->iter_handle;
5000 if (h != v->value_handle)
5003 (void) pthread_mutex_lock(&h->rh_lock);
5008 (void) pthread_mutex_unlock(&h->rh_lock);
5013 (void) pthread_mutex_unlock(&h->rh_lock);
5021 r = make_door_call(h, &request, sizeof (request),
5025 (void) pthread_mutex_unlock(&h->rh_lock);
5030 (void) pthread_mutex_unlock(&h->rh_lock);
5034 (void) pthread_mutex_unlock(&h->rh_lock);
5051 (void) pthread_mutex_unlock(&h->rh_lock);
5059 scf_handle_t *h = prop->rd_d.rd_handle;
5064 if (h != v->value_handle)
5067 (void) pthread_mutex_lock(&h->rh_lock);
5075 r = make_door_call(h, &request, sizeof (request),
5079 (void) pthread_mutex_unlock(&h->rh_lock);
5085 (void) pthread_mutex_unlock(&h->rh_lock);
5099 (void) pthread_mutex_unlock(&h->rh_lock);
5438 scf_handle_decode_fmri(scf_handle_t *h, const char *fmri, scf_scope_t *sc,
5452 if ((sc != NULL && h != sc->rd_d.rd_handle) ||
5453 (svc != NULL && h != svc->rd_d.rd_handle) ||
5454 (inst != NULL && h != inst->rd_d.rd_handle) ||
5455 (pg != NULL && h != pg->rd_d.rd_handle) ||
5456 (prop != NULL && h != prop->rd_d.rd_handle))
5535 handle_hold_subhandles(h, holds);
5537 sc = h->rh_scope;
5542 svc = h->rh_service;
5547 inst = h->rh_instance;
5552 pg = h->rh_pg;
5557 prop = h->rh_property;
5566 if (scf_handle_get_scope(h, SCF_SCOPE_LOCAL, sc) == -1) {
5567 handle_rele_subhandles(h, holds);
5573 handle_rele_subhandles(h, holds);
5580 handle_rele_subhandles(h, holds);
5585 handle_rele_subhandles(h, holds);
5594 handle_rele_subhandles(h, holds);
5601 handle_rele_subhandles(h, holds);
5606 handle_rele_subhandles(h, holds);
5615 handle_rele_subhandles(h, holds);
5625 handle_rele_subhandles(h, holds);
5630 handle_rele_subhandles(h, holds);
5640 handle_rele_subhandles(h, holds);
5645 handle_rele_subhandles(h, holds);
5653 handle_rele_subhandles(h, holds);
5711 scf_handle_t *h = svc->rd_d.rd_handle;
5712 scf_scope_t *scope = HANDLE_HOLD_SCOPE(h);
5719 HANDLE_RELE_SCOPE(h);
5729 HANDLE_RELE_SCOPE(h);
5754 scf_handle_t *h = inst->rd_d.rd_handle;
5755 scf_service_t *svc = HANDLE_HOLD_SERVICE(h);
5762 HANDLE_RELE_SERVICE(h);
5768 HANDLE_RELE_SERVICE(h);
5793 scf_handle_t *h = pg->rd_d.rd_handle;
5801 (void) pthread_mutex_lock(&h->rh_lock);
5806 r = make_door_call(h, &request, sizeof (request),
5808 (void) pthread_mutex_unlock(&h->rh_lock);
5822 svc = HANDLE_HOLD_SERVICE(h);
5829 HANDLE_RELE_SERVICE(h);
5836 inst = HANDLE_HOLD_INSTANCE(h);
5843 HANDLE_RELE_INSTANCE(h);
5848 scf_instance_t *inst = HANDLE_HOLD_INSTANCE(h);
5849 scf_snapshot_t *snap = HANDLE_HOLD_SNAPSHOT(h);
5850 scf_snaplevel_t *level = HANDLE_HOLD_SNAPLVL(h);
5863 HANDLE_RELE_INSTANCE(h);
5864 HANDLE_RELE_SNAPSHOT(h);
5865 HANDLE_RELE_SNAPLVL(h);
5897 scf_handle_t *h = prop->rd_d.rd_handle;
5898 scf_propertygroup_t *pg = HANDLE_HOLD_PG(h);
5906 HANDLE_RELE_PG(h);
5912 HANDLE_RELE_PG(h);
5946 scf_handle_t *h = pg->rd_d.rd_handle;
5953 if (h != out->rd_d.rd_handle)
5961 svc = HANDLE_HOLD_SERVICE(h);
5962 inst = HANDLE_HOLD_INSTANCE(h);
5977 HANDLE_RELE_SERVICE(h);
5978 HANDLE_RELE_INSTANCE(h);
6082 uint_t h = 0, g;
6094 h = (h << 4) + *p;
6095 if ((g = (h & 0xf0000000)) != 0) {
6096 h ^= (g >> 24);
6097 h ^= g;
6101 h %= WALK_HTABLE_SIZE;
6106 for (key = htable[h]; key != NULL; key = key->sk_next) {
6130 key->sk_next = htable[h];
6131 htable[h] = key;
6269 scf_walk_fmri(scf_handle_t *h, int argc, char **argv, int flags,
6329 if ((inst = scf_instance_create(h)) == NULL ||
6330 (svc = scf_service_create(h)) == NULL ||
6331 (iter = scf_iter_create(h)) == NULL ||
6332 (sciter = scf_iter_create(h)) == NULL ||
6333 (siter = scf_iter_create(h)) == NULL ||
6334 (scope = scf_scope_create(h)) == NULL ||
6335 (pg = scf_pg_create(h)) == NULL ||
6336 (prop = scf_property_create(h)) == NULL ||
6337 (value = scf_value_create(h)) == NULL) {
6373 if (scf_handle_decode_fmri(h, argv[i], NULL, NULL,
6414 if (scf_handle_decode_fmri(h, argv[i], NULL, NULL,
6435 if (scf_handle_decode_fmri(h, argv[i], NULL, svc,
6553 if (scf_handle_get_local_scope(h, scope) != 0) {
6901 if (scf_handle_decode_fmri(h, key->sk_fmri,
7316 _scf_request_backup(scf_handle_t *h, const char *name)
7327 (void) pthread_mutex_lock(&h->rh_lock);
7329 request.rpr_changeid = handle_next_changeid(h);
7331 r = make_door_call(h, &request, sizeof (request),
7333 (void) pthread_mutex_unlock(&h->rh_lock);
7359 _scf_repository_switch(scf_handle_t *h, int scf_sw)
7369 (void) pthread_mutex_lock(&h->rh_lock);
7373 request.rpr_changeid = handle_next_changeid(h);
7375 r = make_door_call(h, &request, sizeof (request),
7378 (void) pthread_mutex_unlock(&h->rh_lock);
7422 _scf_set_annotation(scf_handle_t *h, const char *operation, const char *file)
7429 if (h == NULL) {
7447 (void) pthread_mutex_lock(&h->rh_lock);
7448 r = make_door_call(h, &request, sizeof (request),
7450 (void) pthread_mutex_unlock(&h->rh_lock);