.TH GETMNTENT 3 .SH NAME getmntent, getmntany, hasmntopt, putmntent \- interface to /etc/fstab and /etc/mtab .SH SYNOPSIS .ft B .nf #include #include int getmntent(FILE *\fImfp\fP, struct mnttab *\fImtp\fP) int getmntany(FILE *\fImfp\fP, struct mnttab *\fImtp\fP, const struct mnttab *\fIlook\fP) char *hasmntopt(struct mnttab *\fImtp\fP, const char *\fIopt\fP) int putmntent(FILE *\fImfp\fP, const struct mnttab *\fImtp\fP) .fi .ft P .SH DESCRIPTION The .B getmntent functions provide an interface to the /etc/fstab and /etc/mtab files. (See .BR fstab (5)). .PP To read one of these files one calls .B getmntent() several times on a file opened by .BR fopen (3) to read the entries in the table until -1 is returned for end-of-file. .PP .B Getmntany() calls .B getmntent() until it finds an entry that matches .I 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 .B dev and the table contains .BR 1 , .BR 2 , .BR 1f , or .BR 2f . .PP To write to a table you need to open it in a write or append mode and use .B putmntent() to add an entry. .PP .B 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. .PP The struct mnttab is defined by as follows: .sp .nf .ta +4n +6n +15n 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) */ }; .fi .SH "SEE ALSO" .BR fopen (3), .BR fstab (5), .BR mount (1), .BR mount (2). .SH DIAGNOSTICS .B Getmntent() and .B getmntany() return -1 on end-of-file or error, otherwise a nonnegative number is returned: Zero for a successful read, .B MNT_TOOLONG if the line from the table exceeds the internal buffer of .B MNT_LINE_MAX bytes, .B MNT_TOOMANY if a line contains too many fields, and .B MNT_TOOFEW if a line contains too few fields. .PP .B Putmntent() returns the number of bytes written on success, -1 on error. .SH NOTES .B Getmntent() returns a pointer to static storage that is overwritten in each call. .SH AUTHOR Kees J. Bot (kjb@cs.vu.nl) \". \". $PchId: getmntent.3,v 1.3 1995/11/27 20:23:01 philip Exp $