[PATCH 2/3] Fail IDE on IDE disk open errors and tell user about it

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


Makes IDE image opening related errors work similarly to how they're
handled with ACSI/SCSI.
---
 src/ide.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/ide.c b/src/ide.c
index 55a75710..61d4cf69 100644
--- a/src/ide.c
+++ b/src/ide.c
@@ -576,14 +576,21 @@ static int bdrv_open(BlockDriverState *bs, const char *filename, unsigned long b
 		/* Maybe the file is read-only? */
 		bs->fhndl = fopen(filename, "rb");
 		if (!bs->fhndl)
+		{
 			perror("bdrv_open");
+			Log_AlertDlg(LOG_ERROR, "Cannot open IDE HD for reading\n'%s'.\n", filename);
+			return -1;
+		}
+		Log_AlertDlg(LOG_WARN, "IDE HD file is read-only, no writes will go through\n'%s'.\n",
+			     filename);
 		bs->read_only = 1;
 	}
 	else if (!File_Lock(bs->fhndl))
 	{
-		Log_Printf(LOG_ERROR, "Cannot lock IDE HD file for writing!\n");
+		Log_AlertDlg(LOG_ERROR, "Locking IDE HD file for writing failed\n'%s'!\n", filename);
 		fclose(bs->fhndl);
 		bs->fhndl = NULL;
+		return -1;
 	}
 
 	/* call the change callback */
-- 
2.20.1


--------------4C2E2705B1012F3979499840
Content-Type: text/x-patch; charset=UTF-8;
 name="0001-Tell-user-which-HD-type-interface-is-in-question-on-.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename*0="0001-Tell-user-which-HD-type-interface-is-in-question-on-.pa";
 filename*1="tch"



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