@node setmntent, unix @findex setmntent @subheading Syntax @example #include FILE *setmntent(char *filename, const char *mode); @end example @subheading Description This function returns an open @code{FILE*} pointer which can be used by @code{getmntent} (@pxref{getmntent}). The arguments @var{filename} and @var{mode} are always ignored under MS-DOS, but for portability should be set, accordingly, to the name of the file which describes the mounted filesystems and the open mode of that file (like the @var{mode} argument to @code{fopen}, @pxref{fopen}). (There is no single standard for the name of the file that keeps the mounted filesystems, but it is usually, although not always, listed in the header @code{}.) @subheading Return Value The @code{FILE*} pointer is returned. For MS-DOS, this @code{FILE*} is not a real pointer and may only be used by @code{getmntent}. @subheading Portability @portability !ansi, !posix @subheading Example @example #include #if defined(MNT_MNTTAB) #define MNTTAB_FILE MNT_MNTTAB #elif defined(MNTTABNAME) #define MNTTAB_FILE MNTTABNAME #else #define MNTTAB_FILE "/etc/mnttab" #endif FILE *mnt_fp = setmntent (MNTTAB_FILE, "r"); @end example @c ---------------------------------------------------------------------- @node getmntent, unix @findex getmntent @tindex mntent@r{ structure} @subheading Syntax @example #include struct mntent *getmntent(FILE *filep); @end example @subheading Description This function returns information about the various drives that are available to your program. Beginning with drive @file{A:}, information is retrieved for successive drives with successive calls to @code{getmntent}. Note that drives @file{A:} and @file{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 @file{A:/} or @file{B:/}, depending on how it was last referenced (and if there is a disk in the drive). The argument @var{filep} should be a @code{FILE*} pointer returned by @code{setmntent} (@pxref{setmntent}). For each drive scanned, a pointer to a static structure of the following type is returned: @example 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 */ @}; @end example DJGPP implementation returns the following in the first 4 fields of @code{struct mntent}: @table @code @item mnt_fsname For networked and CD-ROM drives, this is the name of root directory in the form @file{\\HOST\PATH} (this is called a @dfn{UNC name}). For drives compressed with DoubleSpace, @code{mnt_fsname} is the string @file{@var{X}:\DBLSPACE.@var{NNN}}, where @var{X} is the drive letter of the host drive and @var{NNN} is the sequence number of the Compressed Volume File. For drives compressed with Stacker, @code{mnt_fsname} is the string @file{@var{X}:\STACVOL.@var{NNN}}, where @var{X} and @var{NNN} are as for DoubleSpace drives. For drives compressed with Jam (a shareware disk compression software), @code{mnt_fsname} is the full name of the Jam archive file. For SUBSTed drives, @code{mnt_fsname} is the actual directory name that that was SUBSTed to emulate a drive. JOINed drives get their @code{mnt_fsname} as if they were NOT JOINed (i.e., either the label name or the default @samp{Drive @var{X}:}). For drives with a volume label, @code{mnt_fsname} is the name of the label; otherwise the string @samp{Drive @var{X}:}, where @var{X} is the drive letter. @item mnt_dir For most drives, this is the name of its root directory @file{@var{X}:/} (where @var{X} is the drive letter), except that JOINed drives get @code{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 @file{a:/} or @file{b:/}), the mount directory will be returned as one of these, depending on which drive letter was last used to reference that drive. @item mnt_type @example "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 @end example @item mnt_opts The string @samp{ro,dev=@var{XX}} for CD-ROM drives, @samp{rw,dev=@var{XX}} for all the others, where @var{XX} is the hexadecimal drive number of the REAL drive on which this filesystem resides. That is, if you call @code{stat} on @var{mnt_fsname}, you will get the numeric equivalent of @var{XX} in @code{st_dev} member of @code{struct stat}. E.g., for drive @file{C:} you will get @samp{rw,dev=02}. Note that SUBSTed and JOINed drives get the drive numbers as if SUBST and JOIN were @strong{not} in effect. @end table @subheading Return Value This function returns a pointer to a @code{struct mntent}, or @code{NULL} if there are no more drives to report on. @subheading Portability @portability !ansi, !posix @subheading Example @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); @end example @c ---------------------------------------------------------------------- @node addmntent, unix @findex addmntent @subheading Syntax @example #include int addmntent(FILE *filep, const struct mntent *mnt); @end example @subheading Description This function is a no-op for MS-DOS, but is provided to assist in Unix ports. @xref{getmntent}. @subheading Return Value This function always returns nonzero to signify an error. @subheading Portability @portability !ansi, !posix @c ---------------------------------------------------------------------- @node hasmntopt, unix @findex hasmntopt @subheading Syntax @example #include char *hasmntopt(const struct mntent *mnt, const char *opt); @end example @subheading Description This function scans the @code{mnt_opts} field of the @code{mntent} structure pointed to by @var{mnt} for a substring that matches @var{opt}. @xref{getmntent}. @subheading Return Value This function returns the address of the substring if a match is found, or @code{NULL} otherwise. @subheading Portability @portability !ansi, !posix @c ---------------------------------------------------------------------- @node endmntent, unix @findex endmntent @subheading Syntax @example #include int endmntent(FILE *filep); @end example @subheading Description This function should be called after the last call to @code{getmntent} (@pxref{getmntent}). @subheading Return Value This function always returns one. @subheading Portability @portability !ansi, !posix