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

Function shm_find_segment

freebsd/kern/sysv_shm.c:229–246  ·  view source on GitHub ↗

* Finds segment either by shmid if is_shmid is true, or by segnum if * is_shmid is false. */

Source from the content-addressed store, hash-verified

227 * is_shmid is false.
228 */
229static struct shmid_kernel *
230shm_find_segment(struct prison *rpr, int arg, bool is_shmid)
231{
232 struct shmid_kernel *shmseg;
233 int segnum;
234
235 segnum = is_shmid ? IPCID_TO_IX(arg) : arg;
236 if (segnum < 0 || segnum >= shmalloced)
237 return (NULL);
238 shmseg = &shmsegs[segnum];
239 if ((shmseg->u.shm_perm.mode & SHMSEG_ALLOCATED) == 0 ||
240 (!shm_allow_removed &&
241 (shmseg->u.shm_perm.mode & SHMSEG_REMOVED) != 0) ||
242 (is_shmid && shmseg->u.shm_perm.seq != IPCID_TO_SEQ(arg)) ||
243 shm_prison_cansee(rpr, shmseg) != 0)
244 return (NULL);
245 return (shmseg);
246}
247
248static void
249shm_deallocate_segment(struct shmid_kernel *shmseg)

Callers 3

kern_shmat_lockedFunction · 0.85
kern_shmctl_lockedFunction · 0.85
oshmctlFunction · 0.85

Calls 1

shm_prison_canseeFunction · 0.85

Tested by

no test coverage detected