www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/04/07/11:00:18

Message-ID: <3167C475.5C39@public1.guangzhou.gd.cn>
Date: Sun, 07 Apr 1996 22:34:45 +0900
From: Wang TianXing <gztxwang AT public1 DOT guangzhou DOT gd DOT cn>
Organization: No Organization
MIME-Version: 1.0
To: DJGPP <djgpp AT delorie DOT com>
Subject: Re: Detecting drives
References: <Pine DOT SUN DOT 3 DOT 91 DOT 960407084756 DOT 22284J-100000 AT is>

Eli Zaretskii wrote:
> 
> On Thu, 4 Apr 1996, Lee Braiden wrote:
> 
> > getmntent() (or whatever it's called =) is no use to me - I'd need to
> > check the drives every time, since it won't show the floppy drives
> > unless there's a disk in them, and that could change every time, and
> > get getmntent() is _really_ slow..
> 
> It's not `getmntent' that is slow, it's the floppy drive!  If your problem
> is to check the floppy drives every time, you won't be able to do much
> faster, because it usually takes two disk accesses to be sure there is a
> disk in the drive (the first access after a disk change returns an error,
> and you must be able to tell whether this is a real error--meaning the
> drive is empty--or just an indication of a new disk).  In `getmntent',
> each disk access just reads sector 0 through a BIOS call--how much faster
> can you get?  The only alternative is to access the floppy controller on
> the port level, but that won't work in some environments (e.g. WinNT)
> where DJGPP can run.  (You could think that DOS calls are also a solution,
> but some DPMI servers will GP fault if you try to access an empty drive
> with a DOS call, so you should hook Int 24h if you want to prevent this.)
> 
> Anyway, if you find a faster way, please tell about it, because maybe
> `getmntent' could be sped up after all.

Well, as I read the info file, getmntent() returns nothing about whatever
is inserted in the floppy drive, so why to spin the drive?

What Lee Braiden wants is "detecting drives", not "detecting disks".  The
best way to determine how many floppy drives are installed is to use
_bios_equiplist().  To determine other drives, you use _dos_getdiskfree() -
if _dos_getdiskfree() reports any error, the drive letter you've just tried
is invalid, otherwise it denotes a valid drive.

If an audio CD is being played in a CD-ROM drive, calling _dos_getdiskfree()
with that drive may stop the audio in some situations.  So, it's better to
check whether a drive is a CD-ROM drive first:

    mov   ax, 0x1500
    xor   bx, bx
    int   0x2f
// bx == number of CD-ROM drives( 0 = no CD-ROM drive installed )
// cx == the first CD-ROM drive( 0 = A:, 1 = B:, ... )

Well, this can't be compiled by DJGPP, but you gurus know how to write it
with __dpmi_whatever() things.


Regards,
Wang TianXing


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019