An application can retrieve information about the file system on a given drive by using DosQueryFSInfo. The file system information includes information on the amount of free storage space on the disk. The storage space is given in number of allocation units (clusters) on the disk. Each cluster has an associated number of sectors; each sector contains a given number of bytes. A typical disk has 512 bytes for each sector and 4 sectors for each cluster. DosSetFSInfo enables an application to change the volume identifier for the disk in the given drive.

The following code fragment obtains information about the file system that is associated with a particular logical drive.

    #define INCL_DOSFILEMGR   /* File System values */
    #include <os2.h>
    #include <stdio.h>

    ULONG   ulDriveNumber;     /* Drive number                 */
    ULONG   ulFSInfoLevel;     /* File system data required    */
    UCHAR   ucFSInfoBuf[40];   /* File system info buffer      */
    ULONG   ulFSInfoBufSize;   /* File system info buffer size */
    APIRET  ulrc;              /* Return code                  */

    ulDriveNumber = 3;              /* Specify drive C                      */

    ulFSInfoLevel = FSIL_ALLOC;     /* Indicate that file system allocation */
                                    /* information is requested             */

    ulFSInfoBufSize = 40;           /* Size of return data buffer           */

    ulrc = DosQueryFSInfo(ulDriveNumber,
                          ulFSInfoLevel,
                          ucFSInfoBuf,
                          ulFSInfoBufSize);

    if (ulrc != 0) {
        printf("DosQueryFSInfo error: return code = %ld", ulrc);
        return;
    }

In this example, the data buffer FSInfoBuf is used to receive information about space allocation within the specified file system.


[Back] [Next]