| 658 | } |
| 659 | |
| 660 | static int |
| 661 | shmget_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 | |
| 686 | static int |
| 687 | shmget_allocate_segment(struct thread *td, key_t key, size_t size, int mode) |
no test coverage detected