The first example displays the volume label associated with a particular drive. The second example provides allocation information for a drive from the file system.
#define INCL_DOSFILEMGR /* File manager values */
#define INCL_DOSERRORS /* DOS error values */
#include <os2.h>
#include <stdio.h>
int main(VOID) {
ULONG ulDriveNumber = 0; /* Drive number */
FSINFO fsBuffer = {0}; /* File system info buffer */
APIRET rc = NO_ERROR; /* Return code */
ulDriveNumber = 3; /* Specify drive C (A=1, B=2, C=3, ...) */
rc = DosQueryFSInfo(ulDriveNumber,
FSIL_VOLSER, /* Request volume information */
&fsBuffer, /* Buffer for information */
sizeof(FSINFO)); /* Size of buffer */
if (rc != NO_ERROR) {
printf("DosQueryFSInfo error: return code = %u\n", rc);
return 1;
} else {
printf("Volume label: '%s'\n", fsBuffer.vol.szVolLabel);
}
return NO_ERROR;
}
#define INCL_DOSFILEMGR /* File Manager values */
#define INCL_DOSERRORS /* DOS Error values */
#include <os2.h>
#include <stdio.h>
int main (VOID) {
FSALLOCATE fsaBuffer = {0}; /* File system info buffer */
APIRET rc = NO_ERROR; /* Return code */
rc = DosQueryFSInfo(3L, /* Drive number 3 (C:) */
FSIL_ALLOC, /* Level 1 allocation info */
(PVOID)&fsaBuffer, /* Buffer */
sizeof(FSALLOCATE)); /* Size of buffer */
if (rc != NO_ERROR) {
printf("DosQueryFSInfo error: return code = %u\n", rc);
return 1;
} else {
printf ("%12ld bytes in each allocation unit.\n",
fsaBuffer.cSectorUnit * fsaBuffer.cbSector);
/* (Sectors per allocation unit) * (Bytes per sector) */
printf ("%12ld total allocation units.\n", fsaBuffer.cUnit);
printf ("%12ld available allocation units on disk.\n", fsaBuffer.cUnitAvail);
}
DosExit(EXIT_THREAD,fsaBuffer.cUnitAvail); /* Return available allocation units
to the initiating process */
return NO_ERROR;
}