How do I determine what file system a drive uses?

16 bit: DosQFsInfo().
32 but: DosQueryFSInfo()

The folling little 16 bit program produces the following output on my computer:

 LOCAL  C:  FAT
 LOCAL  D:  HPFS
 LOCAL  E:  HPFS
 LOCAL  F:  FAT
 REMOTE P:  LAN   \\SERV1\C$
 REMOTE Q:  LAN   \\SERV1\D$
 REMOTE R:  LAN   \\SERV1\E$

Code....

 /* qdisk.c */
 #define INCL_NOPM
 #define INCL_DOS
 #include <os2.h>
 #include <stdio.h>
 #include <stdlib.h>


 void errorRC(USHORT rc)
 {
     char msg[256];
     USHORT bc;
     if(0 != (rc=DosGetMessage(NULL, 0, msg, sizeof(msg), rc,
                               "OSO001.MSG", &bc))) {
         printf("SYS%04u: Unable to access OSO001.MSG\n", rc);
     }
     else DosWrite(2, msg, bc, &bc);
 }

 void qdisk(char drv)
 {
     USHORT rc, len;
     char dev[3];
     void *buf;
     char *p;

     if(drv < 'C')
         return;
     sprintf(dev, "%c:", drv);
     buf = malloc(2048);
     len = 2048;
     rc = DosQFSAttach(dev, 0, FSAIL_QUERYNAME, buf, &len, 0L);
     if(rc){
         errorRC(rc);
         return;
     }
     switch((*(PUSHORT)buf)){
         case FSAT_CHARDEV  : printf("CHAR   "); break;
         case FSAT_PSEUDODEV: printf("DEV    "); break;
         case FSAT_LOCALDRV : printf("LOCAL  "); break;
         case FSAT_REMOTEDRV: printf("REMOTE "); break;
         default: printf("Unknown "); break;
     }
     p = buf;
     p += sizeof(USHORT);    /* itype */
     printf("%-3s ", p+sizeof(USHORT));
     p += (sizeof(USHORT) + (*(USHORT *)p) + 1);    /* cbName */
     printf("%-8s ", p+sizeof(USHORT));
     p += (sizeof(USHORT) + (*(USHORT *)p) + 1);    /* cbFSDName */
     if((*(USHORT *)p))                             /* cbFSAData */
         printf("%s", p+sizeof(USHORT));
     printf("\n");
     free(buf);
 }

 void cdecl main(void)
 {
     char drv;
     USHORT usDisk;
     ULONG ulDrives;
     DosQCurDisk(&usDisk, &ulDrives); /* gets current drive */
     for (drv = 'A'; drv <= 'Z'; drv++) {
         if (ulDrives & 1)		      /* if the drive bit is set, */
             qdisk(drv);
         ulDrives >>= 1;
     }
 }

ps: DosQSysInfo() will return the max path length that your version of OS/2 supports. But since this API is specific to OS/2, and not to a particular drive, it does not answer your original question.

Credit: Peter Fitzsimmons


[Back: How do I use DosMon*() to stuff the kbd buf?]
[Next: How do I get the error message from a DOS API call?]