getmntent(3)


NAME
     getmntent, getmntany, hasmntopt, putmntent - interface to /etc/fstab  and
     /etc/mtab

SYNOPSIS
     #include <stdio.h>
     #include <sys/mnttab.h>

     int getmntent(FILE *mfp, struct mnttab *mtp)
     int getmntany(FILE *mfp, struct mnttab *mtp, const struct mnttab *look)
     char *hasmntopt(struct mnttab *mtp, const char *opt)
     int putmntent(FILE *mfp, const struct mnttab *mtp)

DESCRIPTION
     The getmntent functions  provide  an  interface  to  the  /etc/fstab  and
     /etc/mtab files.  (See fstab(5)).

     To read one of these files one calls getmntent() several times on a  file
     opened  by fopen(3) to read the entries in the table until -1 is returned
     for end-of-file.

     Getmntany() calls getmntent() until it finds an entry that  matches  look
     for  the  device, mount point and type fields.  If one of the fields is a
     null pointer, or equal to  the  field  in  the  table  then  it  matches.
     Devices match when their device numbers are equal, types match if you are
     looking for dev and the table contains 1, 2, 1f, or 2f.

     To write to a table you need to open it in a write or append mode and use
     putmntent() to add an entry.

     Hasmntopt() is a utility function that tells if a table entry has a given
     option,  returning  the  address  of  the  substring  that  matched, null
     otherwise.

     The struct mnttab is defined by <sys/mnttab.h> as follows:

     struct mnttab {
         char  *mnt_special;  /* name of mounted device */
         char  *mnt_mountp;   /* mount point */
         char  *mnt_fstype;   /* type of mount: dev, swap, 1, 2f ... */
         char  *mnt_mntopts;  /* options: ro, rw, noauto, ... */
         char  *mnt_freq;     /* how often to dump (days) */
         char  *mnt_fsckpass; /* fsck pass number */
         char  *mnt_time;     /* time of mount as by time(2) */
     };





SEE ALSO
     fopen(3), fstab(5), mount(1), mount(2).

DIAGNOSTICS
     Getmntent() and getmntany() return -1 on end-of-file or error,  otherwise
     a   nonnegative   number  is  returned:   Zero  for  a  successful  read,
     MNT_TOOLONG if the line from the table exceeds  the  internal  buffer  of
     MNT_LINE_MAX  bytes,  MNT_TOOMANY if a line contains too many fields, and
     MNT_TOOFEW if a line contains too few fields.

     Putmntent() returns the number of bytes written on success, -1 on error.

NOTES
     Getmntent() returns a pointer to static storage that  is  overwritten  in
     each call.

AUTHOR
     Kees J. Bot (kjb@cs.vu.nl)