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

Function shmget_existing

freebsd/kern/sysv_shm.c:660–684  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

658}
659
660static int
661shmget_existing(struct thread *td, size_t size, int shmflg, int mode,
662 int segnum)
663{
664 struct shmid_kernel *shmseg;
665#ifdef MAC
666 int error;
667#endif
668
669 SYSVSHM_ASSERT_LOCKED();
670 KASSERT(segnum >= 0 && segnum < shmalloced,
671 ("segnum %d shmalloced %d", segnum, shmalloced));
672 shmseg = &shmsegs[segnum];
673 if ((shmflg & (IPC_CREAT | IPC_EXCL)) == (IPC_CREAT | IPC_EXCL))
674 return (EEXIST);
675#ifdef MAC
676 error = mac_sysvshm_check_shmget(td->td_ucred, shmseg, shmflg);
677 if (error != 0)
678 return (error);
679#endif
680 if (size != 0 && size > shmseg->u.shm_segsz)
681 return (EINVAL);
682 td->td_retval[0] = IXSEQ_TO_IPCID(segnum, shmseg->u.shm_perm);
683 return (0);
684}
685
686static int
687shmget_allocate_segment(struct thread *td, key_t key, size_t size, int mode)

Callers 1

sys_shmgetFunction · 0.85

Calls 1

mac_sysvshm_check_shmgetFunction · 0.85

Tested by

no test coverage detected