fn balloc(&self, dev: u32, ctx: &KernelCtx<'_, '_>) -> u32 {
        for b in num_iter::range_step(0, self.fs.superblock().size, BPB as u32) {
            let mut bp = hal().disk().read(dev, self.fs.superblock().bblock(b), ctx);
            for bi in 0..cmp::min(BPB as u32, self.fs.superblock().size - b) {
                let m = 1 << (bi % 8);
                if bp.deref_inner_mut().data[(bi / 8) as usize] & m == 0 {
                    // Is block free?
                    bp.deref_inner_mut().data[(bi / 8) as usize] |= m; // Mark block in use.
                    self.write(bp, ctx);
                    self.bzero(dev, b + bi, ctx);
                    return b + bi;
                }
            }
            bp.free(ctx);
        }

        panic!("balloc: out of blocks");
    }
/// Blocks.
/// Allocate a zeroed disk block.
Blocks.
Allocate a zeroed disk block.
Blocks . Allocate a zeroed disk block .
fn balloc(&self, dev: u32, ctx: &KernelCtx<'_, '_>) -> u32 {
        for b in num_iter::range_step(0, self.fs.superblock().size, BPB as u32) {
            let mut bp = hal().disk().read(dev, self.fs.superblock().bblock(b), ctx);
            for bi in 0..cmp::min(BPB as u32, self.fs.superblock().size - b) {
                let m = 1 << (bi % 8);
                if bp.deref_inner_mut().data[(bi / 8) as usize] & m == 0 {
                    // Is block free?
                    bp.deref_inner_mut().data[(bi / 8) as usize] |= m; // Mark block in use.
                    self.write(bp, ctx);
                    self.bzero(dev, b + bi, ctx);
                    return b + bi;
                }
            }
            bp.free(ctx);
        }
        panic!("balloc: out of blocks");
    }
fn balloc ( & self , dev : u32 , ctx : & KernelCtx < ' _ , ' _ > ) -> u32 { for b in num_iter :: range_step ( 0 , self . fs . superblock ( ) . size , BPB as u32 ) { let mut bp = hal ( ) . disk ( ) . read ( dev , self . fs . superblock ( ) . bblock ( b ) , ctx ) ; for bi in 0 .. cmp :: min ( BPB as u32 , self . fs . superblock ( ) . size - b ) { let m = 1 << ( bi % 8 ) ; if bp . deref_inner_mut ( ) . data [ ( bi / 8 ) as usize ] & m == 0 { // Is block free? bp . deref_inner_mut ( ) . data [ ( bi / 8 ) as usize ] |= m ; // Mark block in use. self . write ( bp , ctx ) ; self . bzero ( dev , b + bi , ctx ) ; return b + bi ; } } bp . free ( ctx ) ; } panic ! ( " " ) ; }
Blocks.
Blocks .
&self
dev
u32
ctx
&KernelCtx<'_, '_>
&self
dev
u32
ctx
&KernelCtx<'_, '_>