diff options
author | Moshe Piekarski <dev.rockbox@melachim.net> | 2020-06-30 11:52:53 -0400 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2020-06-30 21:11:52 +0000 |
commit | 7fb438b06c248ef91baddbb47b31180483efb631 (patch) | |
tree | b9590ffedd4507f290193160d2f9182f64a091ea /firmware/common/disk.c | |
parent | 0d24a7176e33dc6f5a67bf672d6ebea033903ce7 (diff) | |
download | rockbox-7fb438b06c248ef91baddbb47b31180483efb631.tar.gz rockbox-7fb438b06c248ef91baddbb47b31180483efb631.zip |
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
Diffstat (limited to 'firmware/common/disk.c')
-rw-r--r-- | firmware/common/disk.c | 72 |
1 files changed, 37 insertions, 35 deletions
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) | |||
185 | disk_sector_multiplier[IF_MD_DRV(drive)] = 1; | 185 | disk_sector_multiplier[IF_MD_DRV(drive)] = 1; |
186 | #endif | 186 | #endif |
187 | 187 | ||
188 | for (int i = CONFIG_DEFAULT_PARTNUM; | ||
189 | volume != -1 && i < 4 && mounted < NUM_VOLUMES_PER_DRIVE; | ||
190 | i++) | ||
191 | { | ||
192 | if (pinfo[i].type == 0 || pinfo[i].type == 5) | ||
193 | continue; /* skip free/extended partitions */ | ||
194 | |||
195 | #ifdef MAX_LOG_SECTOR_SIZE | ||
196 | for (int j = 1; j <= (MAX_LOG_SECTOR_SIZE/SECTOR_SIZE); j <<= 1) | ||
197 | { | ||
198 | if (!fat_mount(IF_MV(volume,) IF_MD(drive,) pinfo[i].start * j)) | ||
199 | { | ||
200 | pinfo[i].start *= j; | ||
201 | pinfo[i].size *= j; | ||
202 | mounted++; | ||
203 | vol_drive[volume] = drive; /* remember the drive for this volume */ | ||
204 | disk_sector_multiplier[drive] = j; | ||
205 | volume_onmount_internal(IF_MV(volume)); | ||
206 | volume = get_free_volume(); /* prepare next entry */ | ||
207 | break; | ||
208 | } | ||
209 | } | ||
210 | #else /* ndef MAX_LOG_SECTOR_SIZE */ | ||
211 | if (!fat_mount(IF_MV(volume,) IF_MD(drive,) pinfo[i].start)) | ||
212 | { | ||
213 | mounted++; | ||
214 | vol_drive[volume] = drive; /* remember the drive for this volume */ | ||
215 | volume_onmount_internal(IF_MV(volume)); | ||
216 | volume = get_free_volume(); /* prepare next entry */ | ||
217 | } | ||
218 | #endif /* MAX_LOG_SECTOR_SIZE */ | ||
219 | } | ||
220 | 188 | ||
221 | if (mounted == 0 && volume != -1) /* none of the 4 entries worked? */ | 189 | /* try "superfloppy" mode */ |
222 | { /* try "superfloppy" mode */ | 190 | DEBUGF("Trying to mount sector 0.\n"); |
223 | DEBUGF("No partition found, trying to mount sector 0.\n"); | ||
224 | 191 | ||
225 | if (!fat_mount(IF_MV(volume,) IF_MD(drive,) 0)) | 192 | if (!fat_mount(IF_MV(volume,) IF_MD(drive,) 0)) |
226 | { | 193 | { |
@@ -232,6 +199,41 @@ int disk_mount(int drive) | |||
232 | vol_drive[volume] = drive; /* remember the drive for this volume */ | 199 | vol_drive[volume] = drive; /* remember the drive for this volume */ |
233 | volume_onmount_internal(IF_MV(volume)); | 200 | volume_onmount_internal(IF_MV(volume)); |
234 | } | 201 | } |
202 | |||
203 | if (mounted == 0 && volume != -1) /* not a "superfloppy"? */ | ||
204 | { | ||
205 | for (int i = CONFIG_DEFAULT_PARTNUM; | ||
206 | volume != -1 && i < 4 && mounted < NUM_VOLUMES_PER_DRIVE; | ||
207 | i++) | ||
208 | { | ||
209 | if (pinfo[i].type == 0 || pinfo[i].type == 5) | ||
210 | continue; /* skip free/extended partitions */ | ||
211 | |||
212 | #ifdef MAX_LOG_SECTOR_SIZE | ||
213 | for (int j = 1; j <= (MAX_LOG_SECTOR_SIZE/SECTOR_SIZE); j <<= 1) | ||
214 | { | ||
215 | if (!fat_mount(IF_MV(volume,) IF_MD(drive,) pinfo[i].start * j)) | ||
216 | { | ||
217 | pinfo[i].start *= j; | ||
218 | pinfo[i].size *= j; | ||
219 | mounted++; | ||
220 | vol_drive[volume] = drive; /* remember the drive for this volume */ | ||
221 | disk_sector_multiplier[drive] = j; | ||
222 | volume_onmount_internal(IF_MV(volume)); | ||
223 | volume = get_free_volume(); /* prepare next entry */ | ||
224 | break; | ||
225 | } | ||
226 | } | ||
227 | #else /* ndef MAX_LOG_SECTOR_SIZE */ | ||
228 | if (!fat_mount(IF_MV(volume,) IF_MD(drive,) pinfo[i].start)) | ||
229 | { | ||
230 | mounted++; | ||
231 | vol_drive[volume] = drive; /* remember the drive for this volume */ | ||
232 | volume_onmount_internal(IF_MV(volume)); | ||
233 | volume = get_free_volume(); /* prepare next entry */ | ||
234 | } | ||
235 | #endif /* MAX_LOG_SECTOR_SIZE */ | ||
236 | } | ||
235 | } | 237 | } |
236 | 238 | ||
237 | disk_writer_unlock(); | 239 | disk_writer_unlock(); |