summaryrefslogtreecommitdiff
path: root/firmware/common/disk.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/common/disk.c')
-rw-r--r--firmware/common/disk.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/firmware/common/disk.c b/firmware/common/disk.c
index 9b6454c9a2..576eede143 100644
--- a/firmware/common/disk.c
+++ b/firmware/common/disk.c
@@ -172,6 +172,8 @@ bool disk_init(IF_MD_NONVOID(int drive))
172 } 172 }
173 } 173 }
174 174
175 // XXX backup GPT header at final LBA of drive...
176
175 while (is_gpt) { 177 while (is_gpt) {
176 /* Re-start partition parsing using GPT */ 178 /* Re-start partition parsing using GPT */
177 uint64_t part_lba; 179 uint64_t part_lba;
@@ -243,20 +245,24 @@ reload:
243 goto skip; /* Any flag makes us ignore this */ 245 goto skip; /* Any flag makes us ignore this */
244 } 246 }
245 tmp = BYTES2INT64(pptr, 32); /* FIRST LBA */ 247 tmp = BYTES2INT64(pptr, 32); /* FIRST LBA */
246 if (tmp > UINT32_MAX) { // XXX revisit when we resize struct partinfo! 248#ifndef STORAGE_64BIT_SECTOR
247 DEBUGF("GPT: partition starts after 2GiB mark\n"); 249 if (tmp > UINT32_MAX) {
250 DEBUGF("GPT: partition starts after 2TiB mark\n");
248 goto skip; 251 goto skip;
249 } 252 }
253#endif
250 if (tmp < 34) { 254 if (tmp < 34) {
251 DEBUGF("GPT: Invalid start LBA\n"); 255 DEBUGF("GPT: Invalid start LBA\n");
252 goto skip; 256 goto skip;
253 } 257 }
254 pinfo[part].start = tmp; 258 pinfo[part].start = tmp;
255 tmp = BYTES2INT64(pptr, 40); /* LAST LBA */ 259 tmp = BYTES2INT64(pptr, 40); /* LAST LBA */
256 if (tmp > UINT32_MAX) { // XXX revisit when we resize struct partinfo! 260#ifndef STORAGE_64BIT_SECTOR
257 DEBUGF("GPT: partition ends after 2GiB mark\n"); 261 if (tmp > UINT32_MAX) {
262 DEBUGF("GPT: partition ends after 2TiB mark\n");
258 goto skip; 263 goto skip;
259 } 264 }
265#endif
260 if (tmp <= pinfo[part].start) { 266 if (tmp <= pinfo[part].start) {
261 DEBUGF("GPT: Invalid end LBA\n"); 267 DEBUGF("GPT: Invalid end LBA\n");
262 goto skip; 268 goto skip;
@@ -264,7 +270,7 @@ reload:
264 pinfo[part].size = tmp - pinfo[part].start + 1; 270 pinfo[part].size = tmp - pinfo[part].start + 1;
265 pinfo[part].type = PARTITION_TYPE_FAT32_LBA; 271 pinfo[part].type = PARTITION_TYPE_FAT32_LBA;
266 272
267 DEBUGF("GPart%d: start: %08lx size: %08lx\n", 273 DEBUGF("GPart%d: start: %016lx size: %016lx\n",
268 part,pinfo[part].start,pinfo[part].size); 274 part,pinfo[part].start,pinfo[part].size);
269 part++; 275 part++;
270 276
@@ -499,13 +505,13 @@ unsigned int volume_get_cluster_size(IF_MV_NONVOID(int volume))
499 return clustersize; 505 return clustersize;
500} 506}
501 507
502void volume_size(IF_MV(int volume,) unsigned long *sizep, unsigned long *freep) 508void volume_size(IF_MV(int volume,) sector_t *sizep, sector_t *freep)
503{ 509{
504 disk_reader_lock(); 510 disk_reader_lock();
505 511
506 if (!CHECK_VOL(volume) || !fat_size(IF_MV(volume,) sizep, freep)) 512 if (!CHECK_VOL(volume) || !fat_size(IF_MV(volume,) sizep, freep))
507 { 513 {
508 if (freep) *sizep = 0; 514 if (sizep) *sizep = 0;
509 if (freep) *freep = 0; 515 if (freep) *freep = 0;
510 } 516 }
511 517