| 209 | #define SYSVSHM_ASSERT_LOCKED() sx_assert(&sysvshmsx, SA_XLOCKED) |
| 210 | |
| 211 | static int |
| 212 | shm_find_segment_by_key(struct prison *pr, key_t key) |
| 213 | { |
| 214 | int i; |
| 215 | |
| 216 | for (i = 0; i < shmalloced; i++) |
| 217 | if ((shmsegs[i].u.shm_perm.mode & SHMSEG_ALLOCATED) && |
| 218 | shmsegs[i].cred != NULL && |
| 219 | shmsegs[i].cred->cr_prison == pr && |
| 220 | shmsegs[i].u.shm_perm.key == key) |
| 221 | return (i); |
| 222 | return (-1); |
| 223 | } |
| 224 | |
| 225 | /* |
| 226 | * Finds segment either by shmid if is_shmid is true, or by segnum if |