[core] fix handling of BFD drives

* A BFD (Big Floppy Disk) is a disk that isn't actually partitioned,
  but where the first data sector starts at sector 0
* Closes #814
This commit is contained in:
Pete Batard 2016-08-21 14:06:15 +02:00
parent 2b0cc9349f
commit d9a928f5bc
3 changed files with 25 additions and 15 deletions

View file

@ -826,6 +826,10 @@ static BOOL ClearMBRGPT(HANDLE hPhysicalDrive, LONGLONG DiskSize, DWORD SectorSi
// with GPT drives that contain a lot of small partitions) we try not not to clear
// sectors further than the lowest partition already residing on the disk.
num_sectors_to_clear = min(SelectedDrive.FirstDataSector, (DWORD)((add1MB ? 2048 : 0) + MAX_SECTORS_TO_CLEAR));
// Special case for big floppy disks (FirstDataSector = 0)
if (num_sectors_to_clear < 4)
num_sectors_to_clear = (DWORD)((add1MB ? 2048 : 0) + MAX_SECTORS_TO_CLEAR);
uprintf("Erasing %d sectors", num_sectors_to_clear);
for (i=0; i<num_sectors_to_clear; i++) {
if ((IS_ERROR(FormatStatus)) || (write_sectors(hPhysicalDrive, SectorSize, i, 1, pBuf) != SectorSize)) {