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

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

getmntent

Syntax

 
#include <mntent.h>

struct mntent *getmntent(FILE *filep);

Description

This function returns information about the various drives that are available to your program. Beginning with drive `A:', information is retrieved for successive drives with successive calls to getmntent. Note that drives `A:' and `B:' will only be returned if there is an MS-DOS formatted disk in the drive; empty drives are skipped. For systems with a single floppy drive, it is returned as if it were mounted on `A:/' or `B:/', depending on how it was last referenced (and if there is a disk in the drive).

The argument filep should be a FILE* pointer returned by setmntent (see section setmntent).

For each drive scanned, a pointer to a static structure of the following type is returned:

 
struct mntent
{
    char * mnt_fsname;  /* The name of this file system */
    char * mnt_dir;     /* The root directory of this file system */
    char * mnt_type;	/* Filesystem type */
    char * mnt_opts;    /* Options, see below */
    int    mnt_freq;    /* -1 */
    int    mnt_passno;  /* -1 */
    long   mnt_time;    /* -1 */
};

DJGPP implementation returns the following in the first 4 fields of struct mntent:

mnt_fsname

For networked and CD-ROM drives, this is the name of root directory in the form `\\HOST\PATH' (this is called a UNC name).

For drives compressed with DoubleSpace, mnt_fsname is the string `X:\DBLSPACE.NNN', where X is the drive letter of the host drive and NNN is the sequence number of the Compressed Volume File.

For drives compressed with Stacker, mnt_fsname is the string `X:\STACVOL.NNN', where X and NNN are as for DoubleSpace drives.

For drives compressed with Jam (a shareware disk compression software), mnt_fsname is the full name of the Jam archive file.

For SUBSTed drives, mnt_fsname is the actual directory name that that was SUBSTed to emulate a drive.

JOINed drives get their mnt_fsname as if they were NOT JOINed (i.e., either the label name or the default `Drive X:').

For drives with a volume label, mnt_fsname is the name of the label; otherwise the string `Drive X:', where X is the drive letter.

mnt_dir

For most drives, this is the name of its root directory `X:/' (where X is the drive letter), except that JOINed drives get mnt_dir as the name of the directory to which they were JOINed.

For systems with a single floppy drive (which can be referenced as either `a:/' or `b:/'), the mount directory will be returned as one of these, depending on which drive letter was last used to reference that drive.

mnt_type

 
 "fd"     for floppy disks
 "hd"     for hard disks
 "dblsp"  for disks compressed with DoubleSpace
 "stac"   for disks compressed with Stacker
 "jam"    for disks compressed with Jam
 "cdrom"  for CD-ROM drives
 "ram"    for RAM disks
 "subst"  for SUBSTed directories
 "join"   for JOINed disks
 "net"    for networked drives

mnt_opts

The string `ro,dev=XX' for CD-ROM drives, `rw,dev=XX' for all the others, where XX is the hexadecimal drive number of the REAL drive on which this filesystem resides. That is, if you call stat on mnt_fsname, you will get the numeric equivalent of XX in st_dev member of struct stat. E.g., for drive `C:' you will get `rw,dev=02'. Note that SUBSTed and JOINed drives get the drive numbers as if SUBST and JOIN were not in effect.

Return Value

This function returns a pointer to a struct mntent, or NULL if there are no more drives to report on.

Portability

ANSI/ISO C No
POSIX No

Example

 
struct mntent *m;
FILE *f;
f = setmntent("/etc/mnttab", "r");
while ((m = getmntent(f)))
  printf("Drive %s, name %s\n", m->mnt_dir, m->mnt_fsname);
endmntent(f);


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

  webmaster     delorie software   privacy  
  Copyright © 2004     Updated Apr 2004