[PATCH 2/3] Disable failing HD images

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


Fixes following issue:
* User starts hatari with IDE: hatari --ide-master disk.img
* User selects same image also for another interface in GUI,
  e.g. for ACSI, and proceeds
  -> Hatari ACSI file locking fails, and it's not mounted
* User ejects IDE image from GUI, leaves ACSI image as-is and proceeds

=> Hatari won't (re-)initialize ACSI as its config did not change, and
   as result ACSI drive won't be mounted to emulation, although it's
   still visible in the GUI as being mounted.

After the change, ACSI image name isn't anymore shown in the GUI after
failure, as it's now disabled.  When user browses it again, he can
just OK the old name, one doesn't need to search for it.
---
 src/hdc.c     | 2 ++
 src/ide.c     | 6 +++++-
 src/ncr5380.c | 2 ++
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/hdc.c b/src/hdc.c
index 509e6a36..8989add2 100644
--- a/src/hdc.c
+++ b/src/hdc.c
@@ -880,6 +880,8 @@ bool HDC_Init(void)
 			continue;
 		if (HDC_InitDevice("ACSI", &AcsiBus.devs[i], ConfigureParams.Acsi[i].sDeviceFile, ConfigureParams.Acsi[i].nBlockSize) == 0)
 			nAcsiPartitions += HDC_PartitionCount(AcsiBus.devs[i].image_file, TRACE_SCSI_CMD, NULL);
+		else
+			ConfigureParams.Acsi[i].bUseDevice = false;
 	}
 	/* set total number of partitions */
 	nNumDrives += nAcsiPartitions;
diff --git a/src/ide.c b/src/ide.c
index 55a75710..c66ebcc5 100644
--- a/src/ide.c
+++ b/src/ide.c
@@ -2733,7 +2733,11 @@ void Ide_Init(void)
 		if (ConfigureParams.Ide[i].bUseDevice)
 		{
 			int is_byteswap;
-			bdrv_open(hd_table[i], ConfigureParams.Ide[i].sDeviceFile, ConfigureParams.Ide[i].nBlockSize, 0);
+			if (bdrv_open(hd_table[i], ConfigureParams.Ide[i].sDeviceFile, ConfigureParams.Ide[i].nBlockSize, 0) < 0)
+			{
+				ConfigureParams.Ide[i].bUseDevice = false;
+				continue;
+			}
 			nIDEPartitions += HDC_PartitionCount(hd_table[i]->fhndl, TRACE_IDE, &is_byteswap);
 			/* Our IDE implementation is little endian by default,
 			 * so we need to byteswap if the image is not swapped! */
diff --git a/src/ncr5380.c b/src/ncr5380.c
index aa8ec992..4c6b7f39 100644
--- a/src/ncr5380.c
+++ b/src/ncr5380.c
@@ -1038,6 +1038,8 @@ bool Ncr5380_Init(void)
 			continue;
 		if (HDC_InitDevice("SCSI", &ScsiBus.devs[i], ConfigureParams.Scsi[i].sDeviceFile, ConfigureParams.Scsi[i].nBlockSize) == 0)
 			nScsiPartitions += HDC_PartitionCount(ScsiBus.devs[i].image_file, TRACE_SCSI_CMD, NULL);
+		else
+			ConfigureParams.Scsi[i].bUseDevice = false;
 	}
 	nNumDrives += nScsiPartitions;
 	if (nScsiPartitions)
-- 
2.20.1


--------------5B665AC7BF12A75683BFBB6E--



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/