pub fn update(&self, tx: &UfsTx<'_>, ctx: &KernelCtx<'_, '_>) {
        let mut bp = hal().disk().read(
            self.dev,
            ctx.kernel().fs().superblock().iblock(self.inum),
            ctx,
        );

        const_assert!(IPB <= mem::size_of::<BufData>() / mem::size_of::<Dinode>());
        const_assert!(mem::align_of::<BufData>() % mem::align_of::<Dinode>() == 0);
        // SAFETY:
        // * dip is aligned properly.
        // * dip is inside bp.data.
        // * dip will not be read.
        let dip = unsafe {
            &mut *(bp.deref_inner_mut().data.as_mut_ptr() as *mut Dinode)
                .add(self.inum as usize % IPB)
        };

        let inner = self.deref_inner();
        match inner.typ {
            InodeType::Device { major, minor } => {
                dip.typ = DInodeType::Device;
                dip.major = major;
                dip.minor = minor;
            }
            InodeType::None => {
                dip.typ = DInodeType::None;
                dip.major = 0;
                dip.minor = 0;
            }
            InodeType::Dir => {
                dip.typ = DInodeType::Dir;
                dip.major = 0;
                dip.minor = 0;
            }
            InodeType::File => {
                dip.typ = DInodeType::File;
                dip.major = 0;
                dip.minor = 0;
            }
        }

        (*dip).nlink = inner.nlink;
        (*dip).size = inner.size;
        (*dip).addr_direct.copy_from_slice(&inner.addr_direct);
        (*dip).addr_indirect = inner.addr_indirect;
        tx.write(bp, ctx);
    }
/// Copy a modified in-memory inode to disk.
/// Must be called after every change to an ip->xxx field
/// that lives on disk.
Copy a modified in-memory inode to disk.
Must be called after every change to an ip->xxx field
that lives on disk.
Copy a modified in - memory inode to disk . Must be called after every change to an ip - > xxx field that lives on disk .
pub fn update(&self, tx: &UfsTx<'_>, ctx: &KernelCtx<'_, '_>) {
        let mut bp = hal().disk().read(
            self.dev,
            ctx.kernel().fs().superblock().iblock(self.inum),
            ctx,
        );
        const_assert!(IPB <= mem::size_of::<BufData>() / mem::size_of::<Dinode>());
        const_assert!(mem::align_of::<BufData>() % mem::align_of::<Dinode>() == 0);
        // SAFETY:
        // * dip is aligned properly.
        // * dip is inside bp.data.
        // * dip will not be read.
        let dip = unsafe {
            &mut *(bp.deref_inner_mut().data.as_mut_ptr() as *mut Dinode)
                .add(self.inum as usize % IPB)
        };
        let inner = self.deref_inner();
        match inner.typ {
            InodeType::Device { major, minor } => {
                dip.typ = DInodeType::Device;
                dip.major = major;
                dip.minor = minor;
            }
            InodeType::None => {
                dip.typ = DInodeType::None;
                dip.major = 0;
                dip.minor = 0;
            }
            InodeType::Dir => {
                dip.typ = DInodeType::Dir;
                dip.major = 0;
                dip.minor = 0;
            }
            InodeType::File => {
                dip.typ = DInodeType::File;
                dip.major = 0;
                dip.minor = 0;
            }
        }
        (*dip).nlink = inner.nlink;
        (*dip).size = inner.size;
        (*dip).addr_direct.copy_from_slice(&inner.addr_direct);
        (*dip).addr_indirect = inner.addr_indirect;
        tx.write(bp, ctx);
    }
pub fn update ( & self , tx : & UfsTx < ' _ > , ctx : & KernelCtx < ' _ , ' _ > ) { let mut bp = hal ( ) . disk ( ) . read ( self . dev , ctx . kernel ( ) . fs ( ) . superblock ( ) . iblock ( self . inum ) , ctx , ) ; const_assert ! ( IPB mem size_of BufData ( ) mem size_of Dinode ( ) ) ; const_assert ! ( mem align_of BufData ( ) mem align_of Dinode ( ) 0 ) ; // SAFETY: // * dip is aligned properly. // * dip is inside bp.data. // * dip will not be read. let dip = unsafe { & mut * ( bp . deref_inner_mut ( ) . data . as_mut_ptr ( ) as * mut Dinode ) . add ( self . inum as usize % IPB ) } ; let inner = self . deref_inner ( ) ; match inner . typ { InodeType :: Device { major , minor } => { dip . typ = DInodeType :: Device ; dip . major = major ; dip . minor = minor ; } InodeType :: None => { dip . typ = DInodeType :: None ; dip . major = 0 ; dip . minor = 0 ; } InodeType :: Dir => { dip . typ = DInodeType :: Dir ; dip . major = 0 ; dip . minor = 0 ; } InodeType :: File => { dip . typ = DInodeType :: File ; dip . major = 0 ; dip . minor = 0 ; } } ( * dip ) . nlink = inner . nlink ; ( * dip ) . size = inner . size ; ( * dip ) . addr_direct . copy_from_slice ( & inner . addr_direct ) ; ( * dip ) . addr_indirect = inner . addr_indirect ; tx . write ( bp , ctx ) ; }
Copy a modified in-memory inode to disk.
Copy a modified in - memory inode to disk .
&self
tx
&UfsTx<'_>
ctx
&KernelCtx<'_, '_>
&self
tx
&UfsTx<'_>
ctx
&KernelCtx<'_, '_>