Skip to content

Commit

Permalink
Disable raw fallback when image is specified through .ini (#39)
Browse files Browse the repository at this point in the history
Changed so that code properly checks for image specified through
any means, not just through filename lookup.
  • Loading branch information
PetteriAimonen authored and morio committed Aug 25, 2022
1 parent 0f79605 commit 04ab950
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/ZuluSCSI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,6 @@ bool findHDDImages()
}
root.close();

// Error if there are 0 image files
if(!foundImage) {
azlog("ERROR: No valid images found!");
blinkStatus(BLINK_ERROR_NO_IMAGES);
}

// Print SCSI drive map
for (int i = 0; i < NUM_SCSIID; i++)
{
Expand Down Expand Up @@ -381,9 +375,10 @@ static void reinitSCSI()
{
scsiDiskResetImages();
readSCSIDeviceConfig();
bool foundImage = findHDDImages();
findHDDImages();

if (foundImage)
// Error if there are 0 image files
if (scsiDiskCheckAnyImagesConfigured())
{
// Ok, there is an image
blinkStatus(BLINK_STATUS_OK);
Expand All @@ -394,7 +389,10 @@ static void reinitSCSI()
azlog("No images found, enabling RAW fallback partition");
scsiDiskOpenHDDImage(RAW_FALLBACK_SCSI_ID, "RAW:0:0xFFFFFFFF", RAW_FALLBACK_SCSI_ID, 0,
RAW_FALLBACK_BLOCKSIZE, false, false);
#else
azlog("No valid image files found!");
#endif
blinkStatus(BLINK_ERROR_NO_IMAGES);
}

scsiPhyReset();
Expand Down
13 changes: 13 additions & 0 deletions src/ZuluSCSI_disk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,19 @@ void scsiDiskLoadConfig(int target_idx)
}
}

bool scsiDiskCheckAnyImagesConfigured()
{
for (int i = 0; i < S2S_MAX_TARGETS; i++)
{
if (g_DiskImages[i].file.isOpen() && (g_DiskImages[i].scsiId & S2S_CFG_TARGET_ENABLED))
{
return true;
}
}

return false;
}

/*******************************/
/* Config handling for SCSI2SD */
/*******************************/
Expand Down
3 changes: 3 additions & 0 deletions src/ZuluSCSI_disk.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ extern "C" {
void scsiDiskResetImages();
bool scsiDiskOpenHDDImage(int target_idx, const char *filename, int scsi_id, int scsi_lun, int blocksize, bool is_cd, bool is_fd);
void scsiDiskLoadConfig(int target_idx);

// Returns true if there is at least one image active
bool scsiDiskCheckAnyImagesConfigured();

0 comments on commit 04ab950

Please sign in to comment.