MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / shmat

Method shmat

source/kernel/ksystem.cpp:603–642  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

601#define SHM_EXEC 0100000 /* execution access */
602
603U32 KSystem::shmat(KThread* thread, U32 shmid, U32 shmaddr, U32 shmflg, U32 rtnAddr, U32* nativeRtnAddr) {
604 U32 permissions = 0;
605 std::shared_ptr<SHM> shm;
606
607 if (shmid & PRIVATE_SHMID) {
608 shm = thread->process->getSHM(shmid);
609 } else {
610 shm = publicShm[shmid];
611 }
612
613 if (!shm) {
614 return -K_EINVAL;
615 }
616 if (shmaddr && (shmflg & SHM_RND)) {
617 shmaddr = shmaddr & ~K_PAGE_MASK;
618 }
619 if (shmaddr && (shmaddr & K_PAGE_MASK)) {
620 return -K_EINVAL;
621 }
622 if (shmflg & SHM_REMAP) {
623 kpanic("syscall_shmat SHM_REMAP not implemented");
624 }
625 if (shmflg & SHM_RDONLY) {
626 permissions = K_PROT_READ;
627 } else {
628 permissions = K_PROT_READ | K_PROT_WRITE;
629 }
630 U32 result = thread->process->memory->mapPages(thread, shmaddr >> K_PAGE_SHIFT, shm->pages, permissions);
631 if (result == 0) {
632 return -K_EINVAL;
633 }
634 if (rtnAddr) {
635 thread->process->memory->writed(rtnAddr, result);
636 }
637 if (nativeRtnAddr) {
638 *nativeRtnAddr = result;
639 }
640 thread->process->attachSHM(result, shm);
641 return 0;
642}
643
644
645U32 KSystem::shmdt(KThread* thread, U32 shmaddr) {

Callers

nothing calls this directly

Calls 5

kpanicFunction · 0.85
getSHMMethod · 0.80
mapPagesMethod · 0.80
attachSHMMethod · 0.80
writedMethod · 0.45

Tested by

no test coverage detected