From 7fb438b06c248ef91baddbb47b31180483efb631 Mon Sep 17 00:00:00 2001 From: Moshe Piekarski Date: Tue, 30 Jun 2020 11:52:53 -0400 Subject: Try mounting as "superfloppy" first This allows for a superfloppy that has MBR-like data in the BPB. this solves FS#12294 while allowing arbitrary partition types. Change-Id: I53880fe7dd53e5015f5f15be0ddba11105fcd778 --- firmware/common/disk.c | 72 ++++++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 35 deletions(-) (limited to 'firmware/common/disk.c') diff --git a/firmware/common/disk.c b/firmware/common/disk.c index 795bed9457..51d033b678 100644 --- a/firmware/common/disk.c +++ b/firmware/common/disk.c @@ -185,42 +185,9 @@ int disk_mount(int drive) disk_sector_multiplier[IF_MD_DRV(drive)] = 1; #endif - for (int i = CONFIG_DEFAULT_PARTNUM; - volume != -1 && i < 4 && mounted < NUM_VOLUMES_PER_DRIVE; - i++) - { - if (pinfo[i].type == 0 || pinfo[i].type == 5) - continue; /* skip free/extended partitions */ - - #ifdef MAX_LOG_SECTOR_SIZE - for (int j = 1; j <= (MAX_LOG_SECTOR_SIZE/SECTOR_SIZE); j <<= 1) - { - if (!fat_mount(IF_MV(volume,) IF_MD(drive,) pinfo[i].start * j)) - { - pinfo[i].start *= j; - pinfo[i].size *= j; - mounted++; - vol_drive[volume] = drive; /* remember the drive for this volume */ - disk_sector_multiplier[drive] = j; - volume_onmount_internal(IF_MV(volume)); - volume = get_free_volume(); /* prepare next entry */ - break; - } - } - #else /* ndef MAX_LOG_SECTOR_SIZE */ - if (!fat_mount(IF_MV(volume,) IF_MD(drive,) pinfo[i].start)) - { - mounted++; - vol_drive[volume] = drive; /* remember the drive for this volume */ - volume_onmount_internal(IF_MV(volume)); - volume = get_free_volume(); /* prepare next entry */ - } - #endif /* MAX_LOG_SECTOR_SIZE */ - } - if (mounted == 0 && volume != -1) /* none of the 4 entries worked? */ - { /* try "superfloppy" mode */ - DEBUGF("No partition found, trying to mount sector 0.\n"); + /* try "superfloppy" mode */ + DEBUGF("Trying to mount sector 0.\n"); if (!fat_mount(IF_MV(volume,) IF_MD(drive,) 0)) { @@ -232,6 +199,41 @@ int disk_mount(int drive) vol_drive[volume] = drive; /* remember the drive for this volume */ volume_onmount_internal(IF_MV(volume)); } + + if (mounted == 0 && volume != -1) /* not a "superfloppy"? */ + { + for (int i = CONFIG_DEFAULT_PARTNUM; + volume != -1 && i < 4 && mounted < NUM_VOLUMES_PER_DRIVE; + i++) + { + if (pinfo[i].type == 0 || pinfo[i].type == 5) + continue; /* skip free/extended partitions */ + + #ifdef MAX_LOG_SECTOR_SIZE + for (int j = 1; j <= (MAX_LOG_SECTOR_SIZE/SECTOR_SIZE); j <<= 1) + { + if (!fat_mount(IF_MV(volume,) IF_MD(drive,) pinfo[i].start * j)) + { + pinfo[i].start *= j; + pinfo[i].size *= j; + mounted++; + vol_drive[volume] = drive; /* remember the drive for this volume */ + disk_sector_multiplier[drive] = j; + volume_onmount_internal(IF_MV(volume)); + volume = get_free_volume(); /* prepare next entry */ + break; + } + } + #else /* ndef MAX_LOG_SECTOR_SIZE */ + if (!fat_mount(IF_MV(volume,) IF_MD(drive,) pinfo[i].start)) + { + mounted++; + vol_drive[volume] = drive; /* remember the drive for this volume */ + volume_onmount_internal(IF_MV(volume)); + volume = get_free_volume(); /* prepare next entry */ + } + #endif /* MAX_LOG_SECTOR_SIZE */ + } } disk_writer_unlock(); -- cgit v1.2.3