Lines Matching refs:perm
512 kipc_perm_t *kperm, struct ipc_perm *perm, model_t model)
522 STRUCT_SET_HANDLE(lperm, model, perm);
545 ipcperm_stat(struct ipc_perm *perm, kipc_perm_t *kperm, model_t model)
549 STRUCT_SET_HANDLE(lperm, model, perm);
780 * Otherwise, a pointer to the ID's perm structure and held ID lock are
784 ipc_lookup(ipc_service_t *service, int id, kipc_perm_t **perm)
805 *perm = result;
817 ipc_hold(ipc_service_t *s, kipc_perm_t *perm)
819 ASSERT(IPC_INDEX(perm->ipc_id) < s->ipcs_tabsz);
820 ASSERT(IPC_LOCKED(s, perm));
821 perm->ipc_ref++;
829 ipc_rele(ipc_service_t *s, kipc_perm_t *perm)
833 ASSERT(IPC_INDEX(perm->ipc_id) < s->ipcs_tabsz);
834 ASSERT(IPC_LOCKED(s, perm));
835 ASSERT(perm->ipc_ref > 0);
837 nref = --perm->ipc_ref;
838 mutex_exit(&s->ipcs_table[IPC_INDEX(perm->ipc_id)].ipct_lock);
841 ASSERT(IPC_FREE(perm)); /* ipc_rmid clears IPC_ALLOC */
842 s->ipcs_dtor(perm);
843 project_rele(perm->ipc_proj);
844 zone_rele_ref(&perm->ipc_zone_ref, ZONE_REF_IPC);
845 kmem_free(perm, s->ipcs_ssize);
855 ipc_rele_locked(ipc_service_t *s, kipc_perm_t *perm)
857 ASSERT(perm->ipc_ref > 1);
858 ASSERT(IPC_INDEX(perm->ipc_id) < s->ipcs_tabsz);
859 ASSERT(IPC_LOCKED(s, perm));
861 perm->ipc_ref--;
915 kipc_perm_t *perm = NULL;
923 if (perm = avl_find(&service->ipcs_keys, &template, &where)) {
924 ASSERT(!IPC_FREE(perm));
927 if ((flag & 0777) & ~perm->ipc_mode) {
929 audit_ipcget(NULL, (void *)perm);
932 *permp = perm;
993 kipc_perm_t *perm = NULL;
1001 error = ipc_keylookup(service, key, flag, &perm);
1002 if (perm != NULL)
1003 index = ipc_lock_internal(service, perm->ipc_id);
1007 ASSERT(perm == NULL);
1011 if (perm) {
1012 ASSERT(!IPC_FREE(perm));
1013 *permp = perm;
1021 perm = kmem_zalloc(service->ipcs_ssize, KM_SLEEP);
1026 kmem_free(perm, service->ipcs_ssize);
1030 perm->ipc_cuid = perm->ipc_uid = crgetuid(cr);
1031 perm->ipc_cgid = perm->ipc_gid = crgetgid(cr);
1032 perm->ipc_zoneid = getzoneid();
1033 perm->ipc_mode = flag & 0777;
1034 perm->ipc_key = key;
1035 perm->ipc_ref = 1;
1036 perm->ipc_id = IPC_ID_INVAL;
1037 *permp = perm;
1058 kipc_perm_t *perm;
1079 (((error = ipc_keylookup(service, key, flag, &perm)) != 0) ||
1080 (perm != NULL))) {
1111 ipc_commit_end(ipc_service_t *service, kipc_perm_t *perm)
1121 (void) project_hold(perm->ipc_proj);
1135 * Update the perm structure.
1137 perm->ipc_mode |= IPC_ALLOC;
1138 perm->ipc_id = (slot->ipct_seq << IPC_SEQ_SHIFT) | index;
1143 slot->ipct_data = perm;
1144 if (perm->ipc_key != IPC_PRIVATE) {
1145 loc = avl_find(&service->ipcs_keys, perm, &where);
1147 avl_insert(&service->ipcs_keys, perm, where);
1149 list_insert_head(&service->ipcs_usedids, perm);
1154 IPC_PROJ_USAGE(perm, service) += 1;
1155 IPC_ZONE_USAGE(perm, service) += 1;
1163 * ipc_lookup and ipc_commit_begin, perm->ipc_proj will be 0 and we
1164 * merely free the perm structure. If called after ipc_commit_begin,
1168 ipc_cleanup(ipc_service_t *service, kipc_perm_t *perm)
1170 ASSERT(IPC_FREE(perm));
1171 if (perm->ipc_proj) {
1174 service->ipcs_dtor(perm);
1176 if (perm->ipc_zone_ref.zref_zone != NULL)
1177 zone_rele_ref(&perm->ipc_zone_ref, ZONE_REF_IPC);
1178 kmem_free(perm, service->ipcs_ssize);
1190 ipc_remove(ipc_service_t *service, kipc_perm_t *perm)
1192 int id = perm->ipc_id;
1196 ASSERT(IPC_LOCKED(service, perm));
1202 if (perm->ipc_key != IPC_PRIVATE)
1203 avl_remove(&service->ipcs_keys, perm);
1204 list_remove(&service->ipcs_usedids, perm);
1205 perm->ipc_mode &= ~IPC_ALLOC;
1212 ASSERT(IPC_PROJ_USAGE(perm, service) > 0);
1213 ASSERT(IPC_ZONE_USAGE(perm, service) > 0);
1214 IPC_PROJ_USAGE(perm, service) -= 1;
1215 IPC_ZONE_USAGE(perm, service) -= 1;
1216 ASSERT(service->ipcs_count || ((IPC_PROJ_USAGE(perm, service) == 0) &&
1217 (IPC_ZONE_USAGE(perm, service) == 0)));
1228 kipc_perm_t *perm;
1233 lock = ipc_lookup(service, id, &perm);
1241 if (secpolicy_ipc_owner(cr, perm) != 0) {
1250 ipc_remove(service, perm);
1254 service->ipcs_rmid(perm);
1256 ipc_rele(service, perm);
1270 kipc_perm_t *perm;
1314 for (perm = list_head(&service->ipcs_usedids); perm != NULL;
1315 perm = list_next(&service->ipcs_usedids, perm)) {
1316 ASSERT(!IPC_FREE(perm));
1317 if (global || perm->ipc_zoneid == zoneid)
1318 ids[numids++] = perm->ipc_id;
1349 kipc_perm_t *perm, *next;
1357 for (perm = list_head(&service->ipcs_usedids); perm != NULL;
1358 perm = next) {
1359 next = list_next(&service->ipcs_usedids, perm);
1360 if (perm->ipc_zoneid != zoneid)
1370 ASSERT(!IPC_FREE(perm));
1371 lock = ipc_lock(service, perm->ipc_id);
1372 ipc_remove(service, perm);
1374 list_insert_tail(&rmlist, perm);
1382 for (perm = list_head(&rmlist); perm != NULL; perm = next) {
1383 next = list_next(&rmlist, perm);
1384 list_remove(&rmlist, perm);
1386 (void) ipc_lock(service, perm->ipc_id);
1389 service->ipcs_rmid(perm);
1392 ipc_rele(service, perm);