Date: Tue, 3 Oct 1995 08:33:20 +0200 (IST) From: Eli Zaretskii To: Armin Herzer Cc: djgpp AT sun DOT soe DOT clarkson DOT edu Subject: Re: Q: checking the status of disk drives On Mon, 2 Oct 1995, Armin Herzer wrote: > I am using biosequip() to find out how many disk drives are installed > and getdfree() to find out if a volume is available (by checking the > value 0xffff of s_clus (I guess)). This method works fine (esp. for > hard disks). But when there is no disk inserted (in disk drive a: or b:) > the program stops with an error message "drive not ready - (A)bort (R)etry > (I)gnore (F)ail" and after pressing a key I get the 0xffff value. > How can I get rid of this error message so that the program does not stop > (and I can create my own error message)? You can either (1) install an Int 24h handler, or (2) check if there a disk in the drive by reading its 1st sector with biosdisk(). In the latter case the call might return a `disk changed' status (I think it's 6), if the disk was just inserted into the drive, in which case you should retry the call; if you get an error after that, there's no disk in the drive. There is also the issue of drives a: and b: being the same physical drive, in which case DOS will pop up an ugly prompt to insert a disk and press a key. A DOS IOCTL (Int 21h/AX=44h) function is available to check whether a given drive is mapped to another drive, so you can avoid that prompt. An example of code which deals with all these calamities, and then some, can be found in the file src/libc/compat/mntent/mntent.c in the v2.0 beta distribution of the C library sources for DJGPP (available at ftp.idsoftware.com:/djgpp/beta/v2/ as djlsr200-beta3.zip).