1
0
mirror of https://github.com/mist-devel/mist-firmware.git synced 2026-05-06 00:04:39 +00:00

Fix 64 bit seek offsets

This commit is contained in:
Gyorgy Szombathelyi
2021-05-25 12:15:33 +02:00
parent 850443d621
commit 7b4589d0a0
2 changed files with 10 additions and 3 deletions

11
hdd.c
View File

@@ -364,7 +364,7 @@ static inline void ATA_ReadSectors(unsigned char* tfr, unsigned short sector, un
int block_count;
lba=chs2lba(cylinder, head, sector, unit);
hdd_debugf("IDE%d: read %d.%d.%d, %d", unit, cylinder, head, sector, sector_count);
hdd_debugf("IDE%d: read %d.%d.%d (%d), %d", unit, cylinder, head, sector, lba, sector_count);
while (sector_count)
{
@@ -687,7 +687,14 @@ void GetHardfileGeometry(hdfTYPE *pHDF)
// HardFileSeek()
unsigned char HardFileSeek(hdfTYPE *pHDF, unsigned long lba)
{
return (f_lseek(&pHDF->idxfile->file, lba * 512) == FR_OK);
FSIZE_t seek_pos = (FSIZE_t) lba << 9;
FRESULT res;
res = f_lseek(&pHDF->idxfile->file, seek_pos);
if (res != FR_OK || f_tell(&pHDF->idxfile->file) != seek_pos) {
hdd_debugf("Seek error: %llu, %llu", seek_pos, f_tell(&pHDF->idxfile->file));
return 0;
}
return 1;
}

View File

@@ -29,5 +29,5 @@ void IDXClose(IDXFile *file) {
}
unsigned char IDXSeek(IDXFile *file, unsigned long lba) {
return f_lseek(&(file->file), lba * 512);
return f_lseek(&(file->file), (FSIZE_t) lba << 9);
}