Skip to content

Commit

Permalink
Skip image if larger than max file size
Browse files Browse the repository at this point in the history
If the target image is larger than the max filesize of the file system
E.g. 4GB on a FAT32 SD card, instead of truncating the image
to the max filesize, skip imaging and emit an error message.

Also fixed an error where a `=` should have been an `|=`
when testing for not enough free space on the SD card.

Modified version of:
BlueSCSI/BlueSCSI-v2@8e9a3c0

Co-authored-by: Eric Helgeson <[email protected]>
  • Loading branch information
morio and erichelgeson committed Oct 19, 2023
1 parent 97c14fb commit 567d2ba
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/ZuluSCSI_initiator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,11 @@ void scsiInitiatorMainLoop()
if (total_bytes >= 0xFFFFFFFF && SD.fatType() != FAT_TYPE_EXFAT)
{
// Note: the FAT32 limit is 4 GiB - 1 byte
logmsg("Image files equal or larger than 4 GiB are only possible on exFAT filesystem");
logmsg("Please reformat the SD card with exFAT format to image this drive fully");

g_initiator_state.sectorcount = (uint32_t)0xFFFFFFFF / g_initiator_state.sectorsize;
logmsg("Will image first 4 GiB - 1 = ", (int)g_initiator_state.sectorcount, " sectors");
logmsg("Target SCSI ID ", g_initiator_state.target_id, " image size is equal or larger than 4 GiB.");
logmsg("This is larger than the max filesize supported by SD card's filesystem");
logmsg("Please reformat the SD card with exFAT format to image this target");
g_initiator_state.drives_imaged |= 1 << g_initiator_state.target_id;
return;
}
}
else if (startstopok)
Expand Down Expand Up @@ -312,7 +312,7 @@ void scsiInitiatorMainLoop()
{
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;
g_initiator_state.drives_imaged |= 1 << g_initiator_state.target_id;
return;
}

Expand Down

0 comments on commit 567d2ba

Please sign in to comment.