To obtain information about block devices, and all character and pseudocharacter devices, including the type of device and the name of the file system driver the device is attached to, use DosQueryFSAttach.

The information can be used to determine if the operating system recognizes that a particular file system is attached to a storage device. This is important to an application that must guarantee such a state. An application of this type must handle the situation where the file system driver that formatted a certain disk was not loaded during system startup. (The user might have omitted the IFS= statement in the CONFIG.SYS. file). In such a situation, the data on the disk could be destroyed because the wrong file system was attached to the disk by default.

The following code fragment returns information about an attached file system.

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

    UCHAR       ucDeviceName[8];  /* Device name or drive letter     */
                                /* string                          */
    ULONG       ulOrdinal;        /* Ordinal of entry in name list   */
    ULONG       ulFSAInfoLevel;   /* Type of attached FSD data       */
                                /* required                        */
    FSQBUFFER2  fsqDataBuffer;    /* Returned data buffer            */
    ULONG       ulDataBufferLen;  /* Buffer length                   */
    APIRET      ulrc;             /* Return code                     */

    strcpy(ucDeviceName,
           "Y:");  /* Logical drive of the attached file system */

    ulFSAInfoLevel = 1;

    ulDataBufferLen = sizeof(FSQBUFFER2);    /* Data buffer length   */

    ulrc = DosQueryFSAttach(ucDeviceName,
                            ulOrdinal,
                            ulFSAInfoLevel,
                            &fsqDataBuffer,
                            &ulDataBufferLen);

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

In this example, information was requested about the drive whose name was specified within the DeviceName variable. After the DosQueryFSAttach call, the DataBuffer structure contained a set of information describing the specified attached file system, and the DataBufferLen variable contained the size of information within the structure.


[Back] [Next]