NFSv2/usr/man/man3/getmntent.3

Compare this file to the similar file:
Show the results in this format:

.\" @(#)getmntent.3 1.6 85/04/04 SMI; from UCB 4.2
.TH GETMNTENT 3 "12 March 1985"
.SH NAME
setmntent, getmntent, addmntent, endmntent, hasmntopt \- get filesystem descriptor file entry
.SH SYNOPSIS
.nf
.ft B
#include <stdio.h>
#include <mntent.h>
.sp.5
FILE *setmntent(filep, type)
char *filep;
char *type;
.sp.5
struct mntent *getmntent(filep)
FILE *filep;
.sp.5
int addmntent(filep, mnt)
FILE *filep;
struct mntent *mnt;
.sp.5
char *hasmntopt(mnt, opt)
struct mntent *mnt;
char *opt;
.sp.5
int endmntent(filep)
FILE *filep;
.fi
.IX  "setmntent function"  ""  "\fLsetmntent\fP \(em get filesystem descriptor file entry"
.IX  "getmntent function"  ""  "\fLgetmntent\fP \(em get filesystem descriptor file entry"
.IX  "addmntent function"  ""  "\fLaddmntent\fP \(em get filesystem descriptor file entry"
.IX  "endmntent function"  ""  "\fLendmntent\fP \(em get filesystem descriptor file entry"
.IX  "hasmntopt function"  ""  "\fLhasmntopt\fP \(em get filesystem descriptor file entry"
.IX  "get filesystem descriptor file entry"  "setmntent"  ""  "\fLsetmntent\fP"
.IX  "get filesystem descriptor file entry"  "getmntent"  ""  "\fLgetmntent\fP"
.IX  "get filesystem descriptor file entry"  "addmntent"  ""  "\fLaddmntent\fP"
.IX  "get filesystem descriptor file entry"  "endmntent"  ""  "\fLendmntent\fP"
.IX  "get filesystem descriptor file entry"  "hasmntopt"  ""  "\fLhasmntopt\fP"
.IX  "filesystem descriptor"  "get file entry"
.SH DESCRIPTION
These routines replace the
.IR getfsent (3)
routines for accessing the filesystem description file
.IR /etc/fstab ,
and the mounted filesystem description file
.IR /etc/mtab .
.PP
.I Setmntent
opens a filesystem description file and returns
a file pointer for use with
.IR getmntent ,
.IR addmntent ,
or
.IR endmntent .
The 
.I type
argument is the same as in
.IR fopen (3).
.I Getmntent
reads the next line from
.I filep
and returns a pointer to an object with the following structure
containing broken-out fields of a line in the filesystem description file,
.IR <mntent.h> .
The fields have meanings described in
.IR fstab (5).
.RS
.PP
.ta \w'#define'u +\w'char\0\0'u +\w'*mnt_fsname;\0\0'u
.nf
struct mntent {
	char	*mnt_fsname;	/* filesystem name */
	char	*mnt_dir;	/* filesystem path prefix */
	char	*mnt_type;	/* 4.2, nfs, swap, or ignore */
	char	*mnt_opts;	/* ro, rw, quota, noquota, hard, soft */
	int	mnt_freq;	/* dump frequency, in days */
	int	mnt_passno;	/* pass number on parallel fsck */
};
.fi
.RE
.PP
.I Addmntent
adds the
.I mntent
structure
.I mnt
to the end of the open file
.IR filep .
Note that
.I filep
has to be opened for writing if this is to work.
.I Hasmntopt
scans the
.I mnt_opts
field of the
.I mntent
structure
.I mnt
for a substring that matches
.IR opt .
It returns the address of the substring if a match is found,
0 otherwise.
.I Endmntent
closes the file.
.SH FILES
/etc/fstab
.br
/etc/mtab
.SH "SEE ALSO"
getfsent(3), fstab(5), mtab(5)
.SH DIAGNOSTICS
Null pointer (0) returned on EOF or error.
.SH BUGS
The returned
.I mntent
structure points to static information that is overwritten in each call.