|
@@ -187,15 +187,16 @@ void scsiInitiatorMainLoop()
|
|
|
scsiInquiry(g_initiator_state.target_id, inquiry_data);
|
|
scsiInquiry(g_initiator_state.target_id, inquiry_data);
|
|
|
LED_OFF();
|
|
LED_OFF();
|
|
|
|
|
|
|
|
|
|
+ uint64_t total_bytes = 0;
|
|
|
if (readcapok)
|
|
if (readcapok)
|
|
|
{
|
|
{
|
|
|
- logmsg("SCSI id ", g_initiator_state.target_id,
|
|
|
|
|
|
|
+ logmsg("SCSI ID ", g_initiator_state.target_id,
|
|
|
" capacity ", (int)g_initiator_state.sectorcount,
|
|
" capacity ", (int)g_initiator_state.sectorcount,
|
|
|
" sectors x ", (int)g_initiator_state.sectorsize, " bytes");
|
|
" sectors x ", (int)g_initiator_state.sectorsize, " bytes");
|
|
|
|
|
|
|
|
g_initiator_state.sectorcount_all = g_initiator_state.sectorcount;
|
|
g_initiator_state.sectorcount_all = g_initiator_state.sectorcount;
|
|
|
|
|
|
|
|
- uint64_t total_bytes = (uint64_t)g_initiator_state.sectorcount * g_initiator_state.sectorsize;
|
|
|
|
|
|
|
+ total_bytes = (uint64_t)g_initiator_state.sectorcount * g_initiator_state.sectorsize;
|
|
|
logmsg("Drive total size is ", (int)(total_bytes / (1024 * 1024)), " MiB");
|
|
logmsg("Drive total size is ", (int)(total_bytes / (1024 * 1024)), " MiB");
|
|
|
if (total_bytes >= 0xFFFFFFFF && SD.fatType() != FAT_TYPE_EXFAT)
|
|
if (total_bytes >= 0xFFFFFFFF && SD.fatType() != FAT_TYPE_EXFAT)
|
|
|
{
|
|
{
|
|
@@ -306,6 +307,15 @@ void scsiInitiatorMainLoop()
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ uint64_t sd_card_free_bytes = (uint64_t)SD.vol()->freeClusterCount() * SD.vol()->bytesPerCluster();
|
|
|
|
|
+ if (sd_card_free_bytes < total_bytes)
|
|
|
|
|
+ {
|
|
|
|
|
+ logmsg("SD Card only has ", (int)(sd_card_free_bytes / (1024 * 1024)),
|
|
|
|
|
+ " MiB - not enough free space to image SCSI ID ", g_initiator_state.target_id);
|
|
|
|
|
+ g_initiator_state.drives_imaged = 1 << g_initiator_state.target_id;
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
g_initiator_state.target_file = SD.open(filename, O_RDWR | O_CREAT | O_TRUNC);
|
|
g_initiator_state.target_file = SD.open(filename, O_RDWR | O_CREAT | O_TRUNC);
|
|
|
if (!g_initiator_state.target_file.isOpen())
|
|
if (!g_initiator_state.target_file.isOpen())
|
|
|
{
|
|
{
|