Skip to content

Commit

Permalink
chore(fs): fix broken internal function
Browse files Browse the repository at this point in the history
When I created read_nth_sector, apparently I forgot to write like half the code
  • Loading branch information
Oakchris1955 committed Jul 31, 2024
1 parent cb9fc18 commit 39e0ea0
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -639,8 +639,7 @@ where
for sector in first_sector_of_cluster
..first_sector_of_cluster + self.fs.sectors_per_cluster() as u32
{
self.fs
.read_nth_sector(self.fs.sector_to_partition_offset(sector).into())?;
self.fs.read_nth_sector(sector.into())?;

let start_index = self.offset as usize % self.fs.sector_size() as usize;

Expand Down Expand Up @@ -919,7 +918,7 @@ where
let props = FSProperties {
sector_size,
cluster_size,
fat_offset: unsafe { boot_record.fat.reserved_sector_count as u32 } * sector_size,
fat_offset: unsafe { boot_record.fat.reserved_sector_count as u32 },
total_clusters: unsafe { boot_record.fat.total_clusters() },
reserved_sectors,
first_data_sector,
Expand Down Expand Up @@ -1038,7 +1037,7 @@ where

'outer: loop {
for chunk in self
.read_nth_sector(self.sector_to_partition_offset(sector).into())?
.read_nth_sector(sector.into())?
.chunks(mem::size_of::<FATDirEntry>())
{
match chunk[0] {
Expand Down Expand Up @@ -1181,8 +1180,11 @@ where
fn read_nth_sector(&mut self, n: u64) -> Result<&Vec<u8>, S::Error> {
// nothing to do if the sector we wanna read is already cached
if n != self.stored_sector {
self.storage.seek(SeekFrom::Start(n))?;
self.storage.seek(SeekFrom::Start(
self.sector_to_partition_offset(n as u32).into(),
))?;
self.storage.read_exact(&mut self.sector_buffer)?;
self.stored_sector = n;
}

Ok(&self.sector_buffer)
Expand Down

0 comments on commit 39e0ea0

Please sign in to comment.