|
@@ -96,15 +96,31 @@ public:
|
|
|
{
|
|
{
|
|
|
m_fsfile = SD.open(filename, O_RDWR);
|
|
m_fsfile = SD.open(filename, O_RDWR);
|
|
|
|
|
|
|
|
|
|
+ uint32_t sectorcount = m_fsfile.size() / SD_SECTOR_SIZE;
|
|
|
uint32_t begin = 0, end = 0;
|
|
uint32_t begin = 0, end = 0;
|
|
|
- if (m_fsfile.contiguousRange(&begin, &end))
|
|
|
|
|
|
|
+ if (m_fsfile.contiguousRange(&begin, &end) && end >= begin + sectorcount)
|
|
|
{
|
|
{
|
|
|
// Convert to raw mapping, this avoids some unnecessary
|
|
// Convert to raw mapping, this avoids some unnecessary
|
|
|
// access overhead in SdFat library.
|
|
// access overhead in SdFat library.
|
|
|
m_israw = true;
|
|
m_israw = true;
|
|
|
m_blockdev = SD.card();
|
|
m_blockdev = SD.card();
|
|
|
m_bgnsector = begin;
|
|
m_bgnsector = begin;
|
|
|
- m_endsector = end;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (end != begin + sectorcount)
|
|
|
|
|
+ {
|
|
|
|
|
+ uint32_t allocsize = end - begin + 1;
|
|
|
|
|
+ azlog("---- NOTE: File ", filename, " has FAT allocated size of ", (int)allocsize, " sectors and file size of ", (int)sectorcount, " sectors");
|
|
|
|
|
+ azlog("---- Due to issue #80 in ZuluSCSI version 1.0.8 and 1.0.9 the allocated size was mistakenly reported to SCSI controller.");
|
|
|
|
|
+ azlog("---- If the drive was formatted using those versions, you may have problems accessing it with newer firmware.");
|
|
|
|
|
+ azlog("---- The old behavior can be restored with setting [SCSI] UseFATAllocSize = 1 in " CONFIGFILE);
|
|
|
|
|
+
|
|
|
|
|
+ if (ini_getbool("SCSI", "UseFATAllocSize", 0, CONFIGFILE))
|
|
|
|
|
+ {
|
|
|
|
|
+ sectorcount = allocsize;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ m_endsector = begin + sectorcount - 1;
|
|
|
m_fsfile.close();
|
|
m_fsfile.close();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|