Path: utzoo!lsuc!sickkids!gw
From: gw@sickkids.UUCP (CFI/Graham Wilson )
Newsgroups: comp.sys.ibm.pc
Subject: DOS Device Error Handling - Need Help
Message-ID: <104@sickkids.UUCP>
Date: 17 Aug 88 20:06:41 GMT
Reply-To: gw@sickkids.UUCP (CFI/Graham Wilson (977-5450) [RICFI7921Z])
Organization: Hospital for Sick Children, Toronto
Lines: 48

Hello all.  I am looking for techniques to cleanly handle device errors in
DOS.  I am mainly interested in trapping floppy disk errors.  I don't like

	Error reading drive A
	Abort, Retry, Ignore ?

showing up on your graphics display because the user forgot to put the data
disk in drive A.

I have used a variety of techiques to deal with this problem, and my current
solution is to intercept BIOS int 0x13 calls.  When an error occurs (i.e.
write protect or disk not ready), then the error is passed via assembler to
my C routine, which flashes a nice window telling the user to fix what ever
is wrong.  The diskette system is resette (int 0x13 service 0) and the disk
command is tried again.  DOS never gets an error returned from BIOS.  It
works just fine (no bugs, no crashes - I'll email the source if you ask).

But, I'm greedy.  I want more!  I want to exit cleanly from disk I/O if
an error occurs.  For example, I want the following to work:


	errortrap_init();

	/*  Drive A is empty */

	fp = fopen("a:file","r");
	if ( fp==0 && errortrap_flag==NODISK )
		printf("No disk in drive A");

	errortrap_term();

Without the annoying DOS error message.  Note that error recovery must be
clean - no hangs and no flags left set which make it difficult retry the
same operation later.

All I can think of is to re-write large chunks of DOS for floppy disk I/O.
I really don't want to do that.  Can anyone help?  Ideas? Thanks bunches
in advance.  Please e-mail.  Will post summary if working solution can be
devised.

Oh yes, if it matters, it should apply to DOS 3.X

Graham Wilson         |   watmath  allegra     decvax
CyberFluor Inc        |        |      |           |  
179 John St, #400     | uunet!utai!utgpu!utzoo!sickkids!gw
Toronto, Ont, M5T 1X4 |        |           |
(416) 977-5450        |  ubc-vision      linus