pub fn sys_vmo_create_child(
        &self,
        handle_value: HandleValue,
        options: u32,
        offset: usize,
        size: usize,
        mut out: UserOutPtr<HandleValue>,
    ) -> ZxResult {
        let mut options = VmoCloneFlags::from_bits(options).ok_or(ZxError::INVALID_ARGS)?;
        info!(
            "vmo_create_child: handle={:#x}, options={:?}, offset={:#x}, size={:#x}",
            handle_value, options, offset, size
        );
        // check options given
        let no_write = options.contains(VmoCloneFlags::NO_WRITE);
        if no_write {
            options.remove(VmoCloneFlags::NO_WRITE);
        }

        let resizable = options.contains(VmoCloneFlags::RESIZABLE);
        let child_size = roundup_pages(size);
        if child_size < size {
            return Err(ZxError::OUT_OF_RANGE);
        }
        info!("size of child vmo: {:#x}", child_size);

        let proc = self.thread.proc();
        let (vmo, parent_rights) = proc.get_object_and_rights::<VmObject>(handle_value)?;
        if !parent_rights.contains(Rights::DUPLICATE | Rights::READ) {
            return Err(ZxError::ACCESS_DENIED);
        }
        let child_vmo = if options.contains(VmoCloneFlags::SLICE) {
            if options != VmoCloneFlags::SLICE {
                Err(ZxError::INVALID_ARGS)
            } else {
                vmo.create_slice(offset, child_size)
            }
        } else {
            // TODO: ZX_VMO_CHILD_SNAPSHOT
            if !options.contains(VmoCloneFlags::SNAPSHOT_AT_LEAST_ON_WRITE) {
                return Err(ZxError::NOT_SUPPORTED);
            }
            vmo.create_child(resizable, offset as usize, child_size)
        }?;
        // generate rights
        let mut child_rights = parent_rights;
        child_rights.insert(Rights::GET_PROPERTY | Rights::SET_PROPERTY);
        if no_write {
            child_rights.remove(Rights::WRITE);
        } else if options.contains(VmoCloneFlags::SNAPSHOT)
            || options.contains(VmoCloneFlags::SNAPSHOT_AT_LEAST_ON_WRITE)
        {
            child_rights.remove(Rights::EXECUTE);
            child_rights.insert(Rights::WRITE);
        };
        info!(
            "parent_rights: {:?} child_rights: {:?}",
            parent_rights, child_rights
        );
        out.write(proc.add_handle(Handle::new(child_vmo, child_rights)))?;
        Ok(())
    }
/// Create a child of an existing VMO (new virtual memory object).
Create a child of an existing VMO (new virtual memory object).
Create a child of an existing VMO ( new virtual memory object ) .
pub fn sys_vmo_create_child(
        &self,
        handle_value: HandleValue,
        options: u32,
        offset: usize,
        size: usize,
        mut out: UserOutPtr<HandleValue>,
    ) -> ZxResult {
        let mut options = VmoCloneFlags::from_bits(options).ok_or(ZxError::INVALID_ARGS)?;
        info!(
            "vmo_create_child: handle={:#x}, options={:?}, offset={:#x}, size={:#x}",
            handle_value, options, offset, size
        );
        // check options given
        let no_write = options.contains(VmoCloneFlags::NO_WRITE);
        if no_write {
            options.remove(VmoCloneFlags::NO_WRITE);
        }
        let resizable = options.contains(VmoCloneFlags::RESIZABLE);
        let child_size = roundup_pages(size);
        if child_size < size {
            return Err(ZxError::OUT_OF_RANGE);
        }
        info!("size of child vmo: {:#x}", child_size);
        let proc = self.thread.proc();
        let (vmo, parent_rights) = proc.get_object_and_rights::<VmObject>(handle_value)?;
        if !parent_rights.contains(Rights::DUPLICATE | Rights::READ) {
            return Err(ZxError::ACCESS_DENIED);
        }
        let child_vmo = if options.contains(VmoCloneFlags::SLICE) {
            if options != VmoCloneFlags::SLICE {
                Err(ZxError::INVALID_ARGS)
            } else {
                vmo.create_slice(offset, child_size)
            }
        } else {
            // TODO: ZX_VMO_CHILD_SNAPSHOT
            if !options.contains(VmoCloneFlags::SNAPSHOT_AT_LEAST_ON_WRITE) {
                return Err(ZxError::NOT_SUPPORTED);
            }
            vmo.create_child(resizable, offset as usize, child_size)
        }?;
        // generate rights
        let mut child_rights = parent_rights;
        child_rights.insert(Rights::GET_PROPERTY | Rights::SET_PROPERTY);
        if no_write {
            child_rights.remove(Rights::WRITE);
        } else if options.contains(VmoCloneFlags::SNAPSHOT)
            || options.contains(VmoCloneFlags::SNAPSHOT_AT_LEAST_ON_WRITE)
        {
            child_rights.remove(Rights::EXECUTE);
            child_rights.insert(Rights::WRITE);
        };
        info!(
            "parent_rights: {:?} child_rights: {:?}",
            parent_rights, child_rights
        );
        out.write(proc.add_handle(Handle::new(child_vmo, child_rights)))?;
        Ok(())
    }
pub fn sys_vmo_create_child ( & self , handle_value : HandleValue , options : u32 , offset : usize , size : usize , mut out : UserOutPtr < HandleValue > , ) -> ZxResult { let mut options = VmoCloneFlags :: from_bits ( options ) . ok_or ( ZxError :: INVALID_ARGS ) ? ; info ! ( " " handle_value options offset size ) ; // check options given let no_write = options . contains ( VmoCloneFlags :: NO_WRITE ) ; if no_write { options . remove ( VmoCloneFlags :: NO_WRITE ) ; } let resizable = options . contains ( VmoCloneFlags :: RESIZABLE ) ; let child_size = roundup_pages ( size ) ; if child_size < size { return Err ( ZxError :: OUT_OF_RANGE ) ; } info ! ( " " child_size ) ; let proc = self . thread . proc ( ) ; let ( vmo , parent_rights ) = proc . get_object_and_rights :: < VmObject > ( handle_value ) ? ; if ! parent_rights . contains ( Rights :: DUPLICATE | Rights :: READ ) { return Err ( ZxError :: ACCESS_DENIED ) ; } let child_vmo = if options . contains ( VmoCloneFlags :: SLICE ) { if options != VmoCloneFlags :: SLICE { Err ( ZxError :: INVALID_ARGS ) } else { vmo . create_slice ( offset , child_size ) } } else { // TODO: ZX_VMO_CHILD_SNAPSHOT if ! options . contains ( VmoCloneFlags :: SNAPSHOT_AT_LEAST_ON_WRITE ) { return Err ( ZxError :: NOT_SUPPORTED ) ; } vmo . create_child ( resizable , offset as usize , child_size ) } ? ; // generate rights let mut child_rights = parent_rights ; child_rights . insert ( Rights :: GET_PROPERTY | Rights :: SET_PROPERTY ) ; if no_write { child_rights . remove ( Rights :: WRITE ) ; } else if options . contains ( VmoCloneFlags :: SNAPSHOT ) || options . contains ( VmoCloneFlags :: SNAPSHOT_AT_LEAST_ON_WRITE ) { child_rights . remove ( Rights :: EXECUTE ) ; child_rights . insert ( Rights :: WRITE ) ; } ; info ! ( " " parent_rights child_rights ) ; out . write ( proc . add_handle ( Handle :: new ( child_vmo , child_rights ) ) ) ? ; Ok ( ( ) ) }
Create a child of an existing VMO (new virtual memory object).
Create a child of an existing VMO ( new virtual memory object ) .
&self
handle_value
HandleValue
options
u32
offset
usize
size
usize
out
UserOutPtr<HandleValue>
&self
handle_value
HandleValue
options
u32
offset
usize
size
usize
out
UserOutPtr<HandleValue>