pub fn dirlink(
        &mut self,
        name: &FileName<DIRSIZ>,
        inum: u32,
        tx: &UfsTx<'_>,
        ctx: &KernelCtx<'_, '_>,
    ) -> Result<(), ()> {
        // Check that name is not present.
        if let Ok((ip, _)) = self.dirlookup(name, ctx) {
            ip.free((tx, ctx));
            return Err(());
        };

        // Look for an empty Dirent.
        let (mut de, off) = self
            .iter_dirents(ctx)
            .find(|(de, _)| de.inum == 0)
            .unwrap_or((Default::default(), self.deref_inner().size));
        de.inum = inum as _;
        de.set_name(name);
        self.write_kernel(&de, off, tx, ctx).expect("dirlink");
        Ok(())
    }
/// Write a new directory entry (name, inum) into the directory dp.
Write a new directory entry (name, inum) into the directory dp.
Write a new directory entry ( name inum ) into the directory dp .
pub fn dirlink(
        &mut self,
        name: &FileName<DIRSIZ>,
        inum: u32,
        tx: &UfsTx<'_>,
        ctx: &KernelCtx<'_, '_>,
    ) -> Result<(), ()> {
        // Check that name is not present.
        if let Ok((ip, _)) = self.dirlookup(name, ctx) {
            ip.free((tx, ctx));
            return Err(());
        };
        // Look for an empty Dirent.
        let (mut de, off) = self
            .iter_dirents(ctx)
            .find(|(de, _)| de.inum == 0)
            .unwrap_or((Default::default(), self.deref_inner().size));
        de.inum = inum as _;
        de.set_name(name);
        self.write_kernel(&de, off, tx, ctx).expect("dirlink");
        Ok(())
    }
pub fn dirlink ( & mut self , name : & FileName < DIRSIZ > , inum : u32 , tx : & UfsTx < ' _ > , ctx : & KernelCtx < ' _ , ' _ > , ) -> Result < ( ) , ( ) > { // Check that name is not present. if let Ok ( ( ip , _ ) ) = self . dirlookup ( name , ctx ) { ip . free ( ( tx , ctx ) ) ; return Err ( ( ) ) ; } ; // Look for an empty Dirent. let ( mut de , off ) = self . iter_dirents ( ctx ) . find ( | ( de , _ ) | de . inum == 0 ) . unwrap_or ( ( Default :: default ( ) , self . deref_inner ( ) . size ) ) ; de . inum = inum as _ ; de . set_name ( name ) ; self . write_kernel ( & de , off , tx , ctx ) . expect ( " " ) ; Ok ( ( ) ) }
Write a new directory entry (name, inum) into the directory dp.
Write a new directory entry ( name inum ) into the directory dp .
&mut self
name
&FileName<DIRSIZ>
inum
u32
tx
&UfsTx<'_>
ctx
&KernelCtx<'_, '_>
&mut self
name
&FileName<DIRSIZ>
inum
u32
tx
&UfsTx<'_>
ctx
&KernelCtx<'_, '_>