pub fn sys_shmat(&self, id: usize, mut addr: VirtAddr, shmflg: usize) -> SysResult {
        let mut shm_identifier = self.linux_process().shm_get(id).ok_or(LxError::EINVAL)?;

        let proc = self.zircon_process();
        let vmar = proc.vmar();
        if addr == 0 {
            // although NULL can be a valid address
            // but in C, NULL is regarded as allocation failure
            // so just skip it
            addr = PAGE_SIZE;
        }
        let shm_guard = shm_identifier.guard.lock();
        let vmo = shm_guard.shared_guard.clone();
        info!(
            "shmat: id: {}, addr = {:#x}, size = {}, flags = {:#x}",
            id,
            addr,
            vmo.len(),
            shmflg
        );
        let addr = vmar.map(
            None,
            vmo.clone(),
            0,
            vmo.len(),
            MMUFlags::READ | MMUFlags::WRITE | MMUFlags::EXECUTE,
        )?;
        shm_identifier.addr = addr;
        self.linux_process().shm_set(id, shm_identifier.clone());

        shm_guard.attach(proc.id() as u32);
        Ok(addr)
    }
/// attaches the shared memory segment identified by shmid to the address space of the calling process.
attaches the shared memory segment identified by shmid to the address space of the calling process.
attaches the shared memory segment identified by shmid to the address space of the calling process .
pub fn sys_shmat(&self, id: usize, mut addr: VirtAddr, shmflg: usize) -> SysResult {
        let mut shm_identifier = self.linux_process().shm_get(id).ok_or(LxError::EINVAL)?;
        let proc = self.zircon_process();
        let vmar = proc.vmar();
        if addr == 0 {
            // although NULL can be a valid address
            // but in C, NULL is regarded as allocation failure
            // so just skip it
            addr = PAGE_SIZE;
        }
        let shm_guard = shm_identifier.guard.lock();
        let vmo = shm_guard.shared_guard.clone();
        info!(
            "shmat: id: {}, addr = {:#x}, size = {}, flags = {:#x}",
            id,
            addr,
            vmo.len(),
            shmflg
        );
        let addr = vmar.map(
            None,
            vmo.clone(),
            0,
            vmo.len(),
            MMUFlags::READ | MMUFlags::WRITE | MMUFlags::EXECUTE,
        )?;
        shm_identifier.addr = addr;
        self.linux_process().shm_set(id, shm_identifier.clone());
        shm_guard.attach(proc.id() as u32);
        Ok(addr)
    }
pub fn sys_shmat ( & self , id : usize , mut addr : VirtAddr , shmflg : usize ) -> SysResult { let mut shm_identifier = self . linux_process ( ) . shm_get ( id ) . ok_or ( LxError :: EINVAL ) ? ; let proc = self . zircon_process ( ) ; let vmar = proc . vmar ( ) ; if addr == 0 { // although NULL can be a valid address // but in C, NULL is regarded as allocation failure // so just skip it addr = PAGE_SIZE ; } let shm_guard = shm_identifier . guard . lock ( ) ; let vmo = shm_guard . shared_guard . clone ( ) ; info ! ( " " id addr vmo len ( ) shmflg ) ; let addr = vmar . map ( None , vmo . clone ( ) , 0 , vmo . len ( ) , MMUFlags :: READ | MMUFlags :: WRITE | MMUFlags :: EXECUTE , ) ? ; shm_identifier . addr = addr ; self . linux_process ( ) . shm_set ( id , shm_identifier . clone ( ) ) ; shm_guard . attach ( proc . id ( ) as u32 ) ; Ok ( addr ) }
attaches the shared memory segment identified by shmid to the address space of the calling process.
attaches the shared memory segment identified by shmid to the address space of the calling process .
&self
id
usize
addr
VirtAddr
shmflg
usize
&self
id
usize
addr
VirtAddr
shmflg
usize