From 647ca9252a7e206e92da1dbf4fc46b68bc700ead Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Harabie=C5=84?= Date: Sat, 8 Dec 2018 19:29:44 +0100 Subject: [PATCH] fix: when formatting FAT32 volume properly clear root directory cluster --- src/fs.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fs.rs b/src/fs.rs index 2b430e2..1dd2842 100644 --- a/src/fs.rs +++ b/src/fs.rs @@ -931,7 +931,7 @@ pub fn format_volume(mut disk: T, options: FormatVolumeOptions alloc_cluster(&mut fat_slice, fat_type, None, None, 1)? }; assert!(root_dir_first_cluster == boot.bpb.root_dir_first_cluster); - let first_data_sector = reserved_sectors as u32 + sectors_per_fat + root_dir_sectors; + let first_data_sector = reserved_sectors as u32 + boot.bpb.sectors_per_all_fats() + root_dir_sectors; let sectors_per_cluster = boot.bpb.sectors_per_cluster; let root_dir_first_sector = ((root_dir_first_cluster - RESERVED_FAT_ENTRIES) * sectors_per_cluster as u32) + first_data_sector;