MCPcopy Create free account
hub / github.com/F-Stack/f-stack / shm_find_segment_by_key

Function shm_find_segment_by_key

freebsd/kern/sysv_shm.c:211–223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

209#define SYSVSHM_ASSERT_LOCKED() sx_assert(&sysvshmsx, SA_XLOCKED)
210
211static int
212shm_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

Callers 1

sys_shmgetFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected