From 567d2ba98d54e71d12c9ac8096facfc701fcc205 Mon Sep 17 00:00:00 2001 From: Morio Date: Thu, 19 Oct 2023 16:37:15 -0700 Subject: [PATCH] Skip image if larger than max file size 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: https://github.com/BlueSCSI/BlueSCSI-v2/pull/80/commits/8e9a3c0bfc2c479901b1c7a5772c0e3c9f4d9ca8 Co-authored-by: Eric Helgeson --- src/ZuluSCSI_initiator.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ZuluSCSI_initiator.cpp b/src/ZuluSCSI_initiator.cpp index 94b181dc..f3d77c21 100644 --- a/src/ZuluSCSI_initiator.cpp +++ b/src/ZuluSCSI_initiator.cpp @@ -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) @@ -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; }