forked from M-Labs/rust-fatfs
fix: do not use hard-coded sector size when dealing with FSInfo sector
Previous code is not working correctly if sector size is different than 512. Creating test for this issue would require another binary blob in repository so I am leaving it without test for now.
This commit is contained in:
parent
77be6dd9d0
commit
e45cfb5188
@ -622,7 +622,7 @@ impl<T: ReadWriteSeek> FileSystem<T> {
|
|||||||
|
|
||||||
// read FSInfo sector if this is FAT32
|
// read FSInfo sector if this is FAT32
|
||||||
let mut fs_info = if fat_type == FatType::Fat32 {
|
let mut fs_info = if fat_type == FatType::Fat32 {
|
||||||
disk.seek(SeekFrom::Start(bpb.fs_info_sector as u64 * 512))?;
|
disk.seek(SeekFrom::Start(bpb.fs_info_sector as u64 * bpb.bytes_per_sector as u64))?;
|
||||||
FsInfoSector::deserialize(&mut disk)?
|
FsInfoSector::deserialize(&mut disk)?
|
||||||
} else {
|
} else {
|
||||||
FsInfoSector::default()
|
FsInfoSector::default()
|
||||||
@ -847,7 +847,7 @@ impl<T: ReadWriteSeek> FileSystem<T> {
|
|||||||
let mut fs_info = self.fs_info.borrow_mut();
|
let mut fs_info = self.fs_info.borrow_mut();
|
||||||
if self.fat_type == FatType::Fat32 && fs_info.dirty {
|
if self.fat_type == FatType::Fat32 && fs_info.dirty {
|
||||||
let mut disk = self.disk.borrow_mut();
|
let mut disk = self.disk.borrow_mut();
|
||||||
disk.seek(SeekFrom::Start(self.bpb.fs_info_sector as u64 * 512))?;
|
disk.seek(SeekFrom::Start(self.offset_from_sector(self.bpb.fs_info_sector as u32)))?;
|
||||||
fs_info.serialize(&mut *disk)?;
|
fs_info.serialize(&mut *disk)?;
|
||||||
fs_info.dirty = false;
|
fs_info.dirty = false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user