fn update_fat<D, T>(
        &mut self,
        controller: &mut Controller<D, T>,
        cluster: Cluster,
        new_value: Cluster,
    ) -> Result<(), Error<D::Error>>
    where
        D: BlockDevice,
        T: TimeSource,
    {
        let mut blocks = [Block::new()];
        let fat_offset = cluster.0 * 2;
        let this_fat_block_num = self.lba_start + self.fat_start.offset_bytes(fat_offset);
        let this_fat_ent_offset = (fat_offset % Block::LEN_U32) as usize;
        controller
            .block_device
            .read(&mut blocks, this_fat_block_num, "read_fat")
            .map_err(Error::DeviceError)?;
        let entry = match new_value {
            Cluster::INVALID => 0xFFF6,
            Cluster::BAD => 0xFFF7,
            Cluster::EMPTY => 0x0000,
            Cluster::END_OF_FILE => 0xFFFF,
            _ => new_value.0 as u16,
        };
        LittleEndian::write_u16(
            &mut blocks[0][this_fat_ent_offset..=this_fat_ent_offset + 1],
            entry,
        );
        controller
            .block_device
            .write(&blocks, this_fat_block_num)
            .map_err(Error::DeviceError)?;
        Ok(())
    }
/// Write a new entry in the FAT
Write a new entry in the FAT
Write a new entry in the FAT
fn update_fat<D, T>(
        &mut self,
        controller: &mut Controller<D, T>,
        cluster: Cluster,
        new_value: Cluster,
    ) -> Result<(), Error<D::Error>>
    where
        D: BlockDevice,
        T: TimeSource,
    {
        let mut blocks = [Block::new()];
        let fat_offset = cluster.0 * 2;
        let this_fat_block_num = self.lba_start + self.fat_start.offset_bytes(fat_offset);
        let this_fat_ent_offset = (fat_offset % Block::LEN_U32) as usize;
        controller
            .block_device
            .read(&mut blocks, this_fat_block_num, "read_fat")
            .map_err(Error::DeviceError)?;
        let entry = match new_value {
            Cluster::INVALID => 0xFFF6,
            Cluster::BAD => 0xFFF7,
            Cluster::EMPTY => 0x0000,
            Cluster::END_OF_FILE => 0xFFFF,
            _ => new_value.0 as u16,
        };
        LittleEndian::write_u16(
            &mut blocks[0][this_fat_ent_offset..=this_fat_ent_offset + 1],
            entry,
        );
        controller
            .block_device
            .write(&blocks, this_fat_block_num)
            .map_err(Error::DeviceError)?;
        Ok(())
    }
fn update_fat < D , T > ( & mut self , controller : & mut Controller < D , T > , cluster : Cluster , new_value : Cluster , ) -> Result < ( ) , Error < D :: Error > > where D : BlockDevice , T : TimeSource , { let mut blocks = [ Block :: new ( ) ] ; let fat_offset = cluster . 0 * 2 ; let this_fat_block_num = self . lba_start + self . fat_start . offset_bytes ( fat_offset ) ; let this_fat_ent_offset = ( fat_offset % Block :: LEN_U32 ) as usize ; controller . block_device . read ( & mut blocks , this_fat_block_num , " " ) . map_err ( Error :: DeviceError ) ? ; let entry = match new_value { Cluster :: INVALID => 0xFFF6 , Cluster :: BAD => 0xFFF7 , Cluster :: EMPTY => 0x0000 , Cluster :: END_OF_FILE => 0xFFFF , _ => new_value . 0 as u16 , } ; LittleEndian :: write_u16 ( & mut blocks [ 0 ] [ this_fat_ent_offset ..= this_fat_ent_offset + 1 ] , entry , ) ; controller . block_device . write ( & blocks , this_fat_block_num ) . map_err ( Error :: DeviceError ) ? ; Ok ( ( ) ) }
Write a new entry in the FAT
Write a new entry in the FAT
&mut self
controller
&mut Controller<D, T>
cluster
Cluster
new_value
Cluster
&mut self
controller
&mut Controller<D, T>
cluster
Cluster
new_value
Cluster