_dos_getdiskfree

Description

Gets disk information using system call 0x36.

#include <dos.h>

#include <errno.h>

unsigned _dos_getdiskfree( unsigned drive, struct _diskfree_t *diskspace );

drive Drive number (default is 0)  
diskspace Buffer to hold disk information  

Remarks

The _dos_getdiskfree routine uses system call 0x36 to obtain information on the disk drive specified by drive. The default drive is 0, drive A is 1, drive B is 2, and so on. Information is returned in the _diskfree_t structure (defined in DOS.H) pointed to by diskspace.

The struct _diskfree_t structure contains the following elements:

Element Description

unsigned total_clusters Total clusters on disk
unsigned avail_clusters Available clusters on disk
unsigned sectors_per_cluster Sectors per cluster
unsigned bytes_per_sector Bytes per sector

Return Value

If successful, the function returns 0. Otherwise, it returns a nonzero value and sets errno to EINVAL, indicating that an invalid drive was specified.

Compatibility

Standards:None

16-Bit:DOS, QWIN, WIN, WIN DLL

32-Bit:None

See Also

_dos_getdrive, _dos_setdrive

Example

/* DGDISKFR.C: This program displays information about the default disk drive.

*/

#include <stdio.h>

#include <dos.h>

void main( void )

{

struct _diskfree_t drive;

/* Get information on default disk drive 0 */

_dos_getdiskfree( 0, &drive );

printf( "total clusters: %d\n", drive.total_clusters );

printf( "available clusters: %d\n", drive.avail_clusters );

printf( "sectors per cluster: %d\n", drive.sectors_per_cluster );

printf( "bytes per sector: %d\n", drive.bytes_per_sector );

}

Output

total clusters: 9013

available clusters: 6030

sectors per cluster: 4

bytes per sector: 512