Jump to content

DosQueryFSInfo: Difference between revisions

From EDM2
Ak120 (talk | contribs)
Ak120 (talk | contribs)
mNo edit summary
Line 1: Line 1:
==Description==
Gets information from a file-system device.
Gets information from a file-system device.


==Syntax==
==Syntax==
<PRE>
  DosQueryFSInfo(disknum, infolevel, pBuf, cbBuf)
#define INCL_DOSFILEMGR
#include <os2.h>
 
ULONG    disknum;    /*  Logical drive number for the disk about which information is to be retrieved. */
ULONG    infolevel;  /*  Level of file information required. */
PVOID    pBuf;      /*  Address of the storage area where the system returns the requested level of file information. */
ULONG    cbBuf;      /*  The length, in bytes, of the buffer that receives the file-system information. */
APIRET    ulrc;      /* Return Code. */
 
ulrc = DosQueryFSInfo(disknum, infolevel,
        pBuf, cbBuf);


</PRE>
==Parameters==
==Parameters==
; disknum (ULONG) - input : Logical drive number for the disk about which information is to be retrieved.
;disknum (ULONG) - input : Logical drive number for the disk about which information is to be retrieved.
 
:This parameter can be any value from 0 through 26. If this parameter is zero, information about the disk in the current drive is retrieved. Otherwise, 1 specifies drive A, 2 specifies drive B, and so on.
This parameter can be any value from 0 through 26. If this parameter is zero, information about the disk in the current drive is retrieved. Otherwise, 1 specifies drive A, 2 specifies drive B, and so on.
:When a logical drive is specified, the media in the drive is examined (for a local drive only), and the request is passed to the file system driver (FSD) responsible for managing that media, or to the FSD that is attached to the drive.
 
;infolevel (ULONG) - input : Level of file information required.
When a logical drive is specified, the media in the drive is examined (for a local drive only), and the request is passed to the file system driver (FSD) responsible for managing that media, or to the FSD that is attached to the drive.  
:Possible levels are described in the list below:
 
::1 FSIL_ALLOC   Level 1 information
; infolevel (ULONG) - input : Level of file information required.
::2 FSIL_VOLSER   Level 2 information
 
;pBuf (PVOID) - output : Address of the storage area where the system returns the requested level of file information.
Possible levels are described in the list below:
:'''Level 1 Information:''' When a value of 1 (FSIL_ALLOC) is specified for infolevel, the information is returned in the format of an FSALLOCATE structure.
 
:'''Level 2 Information:''' When a value of 2 (FSIL_VOLSER) is specified for infolevel, the information is returned in the format of an FSINFO structure.
    1 FSIL_ALLOC  
;cbBuf (ULONG) - input : The length, in bytes, of the buffer that receives the file-system information.  
    Level 1 information
    2 FSIL_VOLSER
    Level 2 information  
 
; pBuf (PVOID) - output : Address of the storage area where the system returns the requested level of file information.
 
'''Level 1 Information:''' When a value of 1 (FSIL_ALLOC) is specified for infolevel, the information is returned in the format of an FSALLOCATE structure.
 
'''Level 2 Information:''' When a value of 2 (FSIL_VOLSER) is specified for infolevel, the information is returned in the format of an FSINFO structure.  
 
; cbBuf (ULONG) - input : The length, in bytes, of the buffer that receives the file-system information.  


==Return Code==
==Return Code==
  ulrc (APIRET) - returns
  ulrc (APIRET) - returns
DosQueryFSInfo returns one of the following values:
DosQueryFSInfo returns one of the following values:
 
* 0          NO_ERROR
* 0          NO_ERROR  
* 15        ERROR_INVALID_DRIVE
* 15        ERROR_INVALID_DRIVE  
* 111        ERROR_BUFFER_OVERFLOW
* 111        ERROR_BUFFER_OVERFLOW  
* 124        ERROR_INVALID_LEVEL
* 124        ERROR_INVALID_LEVEL  
* 125        ERROR_NO_VOLUME_LABEL
* 125        ERROR_NO_VOLUME_LABEL


Line 89: Line 62:
     return NO_ERROR;
     return NO_ERROR;
   }
   }
 
</PRE>
<PRE>
#define INCL_DOSFILEMGR  /* File Manager values */
#define INCL_DOSFILEMGR  /* File Manager values */
#define INCL_DOSERRORS    /* DOS Error values    */
#define INCL_DOSERRORS    /* DOS Error values    */
Line 118: Line 92:
   return NO_ERROR;
   return NO_ERROR;
}
}
</PRE>


</PRE>
==Related Functions==
==Related Functions==
*[[DosSetFSInfo]]
*[[DosSetFSInfo]]


[[Category:Dos]]
[[Category:Dos]]

Revision as of 23:15, 28 March 2017

Gets information from a file-system device.

Syntax

DosQueryFSInfo(disknum, infolevel, pBuf, cbBuf)

Parameters

disknum (ULONG) - input
Logical drive number for the disk about which information is to be retrieved.
This parameter can be any value from 0 through 26. If this parameter is zero, information about the disk in the current drive is retrieved. Otherwise, 1 specifies drive A, 2 specifies drive B, and so on.
When a logical drive is specified, the media in the drive is examined (for a local drive only), and the request is passed to the file system driver (FSD) responsible for managing that media, or to the FSD that is attached to the drive.
infolevel (ULONG) - input
Level of file information required.
Possible levels are described in the list below:
1 FSIL_ALLOC Level 1 information
2 FSIL_VOLSER Level 2 information
pBuf (PVOID) - output
Address of the storage area where the system returns the requested level of file information.
Level 1 Information: When a value of 1 (FSIL_ALLOC) is specified for infolevel, the information is returned in the format of an FSALLOCATE structure.
Level 2 Information: When a value of 2 (FSIL_VOLSER) is specified for infolevel, the information is returned in the format of an FSINFO structure.
cbBuf (ULONG) - input
The length, in bytes, of the buffer that receives the file-system information.

Return Code

ulrc (APIRET) - returns

DosQueryFSInfo returns one of the following values:

  • 0 NO_ERROR
  • 15 ERROR_INVALID_DRIVE
  • 111 ERROR_BUFFER_OVERFLOW
  • 124 ERROR_INVALID_LEVEL
  • 125 ERROR_NO_VOLUME_LABEL

Remarks

DosQueryFSInfo gets information from a file-system device.

If the disk or diskette has no volume label, the volume label is returned as a null string.

Trailing blanks supplied at the time the volume label is defined are not considered part of the label and are not returned by DosQueryFSInfo.

Example Code

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;
}

Related Functions