delorie.com/djgpp/doc/libc/libc_379.html   search  
libc.a reference

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

_get_fs_type

Syntax

 
#include <dos.h>

int _get_fs_type( const int drive,
                  char *const result_str );

Description

This function tries to extract the file system type of the drive number drive, 1 == A:, 2 == B:, etc., 0 == default drive. It does this by calling INT21, AX=0x6900, Get Disk Serial Number (sic!), which returns, among other things, an eight character field which is set while formatting the drive. Now, this field can be set to whatever the formatting program wishes, but so far every FAT formatted drive has returned a string starting with "FAT".

If successful the result is put in result_str which must be at least 9 characters long. If unsuccessful errno is set.

This function will not succeed on DOS version < 4, setting errno to ENOSYS. It is also known to have trouble detecting the file system type of disks formatted with a later version of DOS than the version it is run on. E. g. floppies with LFN entries can cause this function to fail or detect the floppy as FAT16 if used in plain DOS.

If you are interested in which kind of FAT file system that is in use try the function _get_fat_size (see section _get_fat_size) which will reliably detect the right kind of FAT file system.

Return Value

0 if the file system type was extracted successfully; otherwise -1.

Portability

ANSI/ISO C No
POSIX No

Example

 
#include <stdio.h>
#include <dos.h>

int main(void)
{
  char buffer[9];

  if( ! _get_fs_type( 3, buffer ) )
  {
    printf("The file system on C: is '%s'.\n", buffer);
  }

  exit(0);
}


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster     delorie software   privacy  
  Copyright © 2004     Updated Apr 2004