Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to index page
Thread view  Board view
SuperIlu

Homepage

Berlin, Germany,
07.07.2023, 21:14
 

Detect the available drives on DOS (Developers)

Hi,

I face an interesting problem for a file selection dialog I want to create:
How do I detect which drive letters are actually available/used in DOS (using either DJGPP or a DOS/BIOS INT)?

I guess it is always safe to assume A, B and C are there?
What happens when no secondary disk drive is installed?
I found _dos_setdrive() in DJGPP and INT21 0Eh, but I'm not sure what happens when I _set_drive() with a non existing drive?
Also the return value is "the highest drive present", so that won't help me with gaps (e.g. A present, B isn't, C is, D-W are not and X is a mapped network drive).
Also, there is the 'undocumented' INT21 32h. Would that work for network-drives as well?

What would be the best practice to only find available drives (like e.g. DosZip file commander does)?

cheers
Ilu

---
Javascript on MS-DOS? Try DOjS https://github.com/SuperIlu/DOjS
Fediverse: @dec_hl@mastodon.social

CandyMan

07.07.2023, 21:41

@ SuperIlu
 

Detect the available drives on DOS

You set the default disk (function 0Eh) and then check if the default is the one you set (function 19h).

function DriveValid(Drive:Char):Boolean;
assembler;asm
        MOV     CL,Drive
        MOV     AH,$19
        INT     $21
        MOV     BL,AL
        MOV     DL,CL
        SUB     DL,'A'
        MOV     AH,$0E
        INT     $21
        MOV     AH,$19
        INT     $21
        XOR     CL,CL
        CMP     AL,DL
        JNE     @@1
        MOV     CL,1
        MOV     DL,BL
        MOV     AH,$0E
        INT     $21
@@1:    XCHG    EAX,ECX
end;

--------D-2119-------------------------------
INT 21 - DOS 1+ - GET CURRENT DEFAULT DRIVE
        AH = 19h
Return: AL = drive (00h = A:, 01h = B:, etc)
Note:   Novell NetWare uses the fact that DOS 2.x COMMAND.COM issues this call
          from a particular location every time it starts a command to
          determine when to issue an automatic EOJ
--------D-210E-------------------------------
INT 21 - DOS 1+ - SELECT DEFAULT DRIVE
        AH = 0Eh
        DL = new default drive (00h = A:, 01h = B:, etc)
Return: AL = number of potentially valid drive letters
Notes:  under Novell NetWare, the return value is always 32, the number of
          drives that NetWare supports
        under DOS 3.0+, the return value is the greatest of 5, the value of
          LASTDRIVE= in CONFIG.SYS, and the number of drives actually present
        on a DOS 1.x/2.x single-floppy system, AL returns 2 since the floppy
          may be accessed as either A: or B:
        otherwise, the return value is the highest drive actually present
        DOS 1.x supports a maximum of 16 drives, 2.x a maximum of 63 drives,
          and 3+ a maximum of 26 drives
        under Novell DOS 7, this function returns the correct LASTDRIVE value
          even when the undocumented LASTDRIVE=27..32 directive was used in
          CONFIG.SYS
        "parse FCB" (see AH=29h) can be used to determine whether a drive
          letter is valid

SuperIlu

Homepage

Berlin, Germany,
07.07.2023, 23:04

@ CandyMan
 

Detect the available drives on DOS

> You set the default disk (function 0Eh) and then check if the default is
> the one you set (function 19h).


Thanks, that sounds like a plan! This does not trigger a disk access, right? So it would work even when there is no disk in A or B?

---
Javascript on MS-DOS? Try DOjS https://github.com/SuperIlu/DOjS
Fediverse: @dec_hl@mastodon.social

Laaca

Homepage

Czech republic,
08.07.2023, 10:36

@ SuperIlu
 

Detect the available drives on DOS

> Thanks, that sounds like a plan! This does not trigger a disk access,
> right? So it would work even when there is no disk in A or B?


I can confirm that this method (func 0Eh and func 19h) works nice and I also use it in my programs.
It does not trigger the disk access.

What can be chalanging is the detection of the fantom drives (I HATE this feature and I am disappointed that FreeDOS kernel maintainers refused my proposal to add the switch to remove this "feature")

---
DOS-u-akbar!

SuperIlu

Homepage

Berlin, Germany,
09.07.2023, 00:11

@ Laaca
 

Detect the available drives on DOS

> I can confirm that this method (func 0Eh and func 19h) works nice and I
> also use it in my programs.
Yeah, thanks. As far as I can tell for now it is working...

---
Javascript on MS-DOS? Try DOjS https://github.com/SuperIlu/DOjS
Fediverse: @dec_hl@mastodon.social

ecm

Homepage E-mail

Düsseldorf, Germany,
07.07.2023, 22:02

@ SuperIlu
 

Detect the available drives on DOS

> Also, there is the 'undocumented' INT21 32h. Would that work for
> network-drives as well?

No, definitely not, as this function deals in DPBs which redirector drives do not have. Refer to the interrupt list: http://fd.lod.bz/rbil/interrup/dos_kernel/2132.html#2763

---
l

Rugxulo

Homepage

Usono,
08.07.2023, 07:56

@ SuperIlu
 

Detect the available drives on DOS

Does this help?

Detecting floppy disk drives

marcov

09.07.2023, 23:18

@ SuperIlu
 

Detect the available drives on DOS

> Hi,
>
> I face an interesting problem for a file selection dialog I want to
> create:
> How do I detect which drive letters are actually available/used in DOS
> (using either DJGPP or a DOS/BIOS INT)?

Do it as little as possible (e.g. only in a setup program). People with DVD/CD changers will thank you.

SuperIlu

Homepage

Berlin, Germany,
10.07.2023, 18:15

@ marcov
 

Detect the available drives on DOS

> Do it as little as possible (e.g. only in a setup program). People with
> DVD/CD changers will thank you.

LOL, it is done once at program start :-D

---
Javascript on MS-DOS? Try DOjS https://github.com/SuperIlu/DOjS
Fediverse: @dec_hl@mastodon.social

Back to index page
Thread view  Board view
22049 Postings in 2034 Threads, 396 registered users, 53 users online (0 registered, 53 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum