]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/getmntent.3
Wrapped long lines, wrapped at sentence boundaries; stripped trailing
[thirdparty/man-pages.git] / man3 / getmntent.3
CommitLineData
fea681da
MK
1.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2.\"
3.\" Permission is granted to make and distribute verbatim copies of this
4.\" manual provided the copyright notice and this permission notice are
5.\" preserved on all copies.
6.\"
7.\" Permission is granted to copy and distribute modified versions of this
8.\" manual under the conditions for verbatim copying, provided that the
9.\" entire resulting derived work is distributed under the terms of a
10.\" permission notice identical to this one.
c13182ef 11.\"
fea681da
MK
12.\" Since the Linux kernel and libraries are constantly changing, this
13.\" manual page may be incorrect or out-of-date. The author(s) assume no
14.\" responsibility for errors or omissions, or for damages resulting from
15.\" the use of the information contained herein. The author(s) may not
16.\" have taken the same level of care in the production of this manual,
17.\" which is licensed free of charge, as they might when working
18.\" professionally.
c13182ef 19.\"
fea681da
MK
20.\" Formatted or processed versions of this manual, if unaccompanied by
21.\" the source, must acknowledge the copyright and authors of this work.
22.\"
23.\" References consulted:
24.\" Linux libc source code
25.\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
26.\" 386BSD man pages
27.\" Modified Sat Jul 24 21:46:57 1993 by Rik Faith (faith@cs.unc.edu)
28.\" Modified 961109, 031115, aeb
29.\"
30.TH GETMNTENT 3 2003-11-15 "" "Linux Programmer's Manual"
31.SH NAME
32getmntent, setmntent, addmntent, endmntent, hasmntopt,
33getmntent_r \- get file system descriptor file entry
34.SH SYNOPSIS
35.nf
36.B #include <stdio.h>
37.B #include <mntent.h>
38.sp
39.BI "FILE *setmntent(const char *" filename ", const char *" type );
40.sp
41.BI "struct mntent *getmntent(FILE *" fp );
42.sp
43.BI "int addmntent(FILE *" fp ", const struct mntent *" mnt );
44.sp
45.BI "int endmntent(FILE *" fp );
46.sp
47.BI "char *hasmntopt(const struct mntent *" mnt ", const char *" opt );
48.sp
49/* GNU extension */
c10859eb 50.BR "#define _GNU_SOURCE" " /* or _SVID_SOURCE or _BSD_SOURCE */"
fea681da
MK
51.B #include <mntent.h>
52.sp
53.BI "struct mntent *getmntent_r(FILE *" fp ", struct mntent *" mntbuf ,
54.BI " char *" buf ", int " buflen );
55.fi
56.SH DESCRIPTION
c13182ef 57These routines are used to access the file system description file
fea681da
MK
58\fI/etc/fstab\fP and the mounted file system description file
59\fI/etc/mtab\fP.
60.PP
63aa9df0 61The \fBsetmntent\fP() function opens the file system description file
fea681da 62\fIfp\fP and returns a file pointer which can be used by
c13182ef
MK
63\fBgetmntent\fP().
64The argument \fItype\fP is the type of access
65required and can take the same values as the \fImode\fP argument of
fea681da
MK
66.BR fopen (3).
67.PP
63aa9df0 68The \fBgetmntent\fP() function reads the next line from the file system
fea681da 69description file \fIfp\fP and returns a pointer to a structure
c13182ef
MK
70containing the broken out fields from a line in the file.
71The pointer
fea681da 72points to a static area of memory which is overwritten by subsequent
63aa9df0 73calls to \fBgetmntent\fP().
fea681da 74.PP
63aa9df0 75The \fBaddmntent\fP() function adds the mntent structure \fImnt\fP to
fea681da
MK
76the end of the open file \fIfp\fP.
77.PP
63aa9df0 78The \fBendmntent\fP() function closes the file system description file
fea681da
MK
79\fIfp\fP.
80.PP
63aa9df0 81The \fBhasmntopt\fP() function scans the \fImnt_opts\fP field (see below)
fea681da
MK
82of the mntent structure \fImnt\fP for a substring that matches \fIopt\fP.
83See \fI<mntent.h>\fP and
84.BR mount (8)
85for valid mount options.
86.PP
63aa9df0 87The reentrant \fBgetmntent_r\fP() function is similar to \fBgetmntent\fP(),
fea681da
MK
88but stores the struct mount in the provided
89.RI * mntbuf
90and stores the strings pointed to by the entries in that struct
91in the provided array
92.I buf
93of size
94.IR buflen .
95.PP
96The \fImntent\fP structure is defined in \fI<mntent.h>\fP as follows:
97.sp
7295b7ed 98.in +0.5i
fea681da 99.nf
fea681da 100struct mntent {
7295b7ed
MK
101 char *mnt_fsname; /* name of mounted file system */
102 char *mnt_dir; /* file system path prefix */
103 char *mnt_type; /* mount type (see mntent.h) */
104 char *mnt_opts; /* mount options (see mntent.h) */
105 int mnt_freq; /* dump frequency in days */
106 int mnt_passno; /* pass number on parallel fsck */
fea681da 107};
fea681da 108.fi
7295b7ed 109.in -0.5i
fea681da
MK
110
111Since fields in the mtab and fstab files are separated by whitespace,
112octal escapes are used to represent the four characters space (\e040),
113tab (\e011), newline (\e012) and backslash (\e134) in those files
114when they occur in one of the four strings in a mntent structure.
63aa9df0 115The routines \fBaddmntent\fP() and \fBgetmntent\fP() will convert
fea681da
MK
116from string representation to escaped representation and back.
117.SH "RETURN VALUE"
63aa9df0 118The \fBgetmntent\fP() and \fBgetmntent_r\fP() functions return
fea681da
MK
119a pointer to the mntent structure or NULL on failure.
120.PP
63aa9df0 121The \fBaddmntent\fP() function returns 0 on success and 1 on failure.
fea681da 122.PP
63aa9df0 123The \fBendmntent\fP() function always returns 1.
fea681da 124.PP
63aa9df0 125The \fBhasmntopt\fP() function returns the address of the substring if
fea681da
MK
126a match is found and NULL otherwise.
127.SH FILES
128.nf
129/etc/fstab file system description file
130/etc/mtab mounted file system description file
131.fi
132.SH "CONFORMING TO"
133The non-reentrant functions are from SunOS 4.1.3.
134A routine
63aa9df0 135.BR getmntent_r ()
c13182ef 136was introduced in HP-UX 10, but it returns an int.
68e1685c 137The prototype shown above is glibc-only.
fea681da 138LSB deprecates the functions
63aa9df0
MK
139.BR endhostent (),
140.BR sethostent ()
fea681da 141and
63aa9df0 142.BR setmntent ().
fea681da 143.SH NOTES
aa651b39 144System V also has a \fBgetmntent\fP() function but the calling sequence
c13182ef
MK
145differs, and the returned structure is different.
146Under System V
fea681da
MK
147.I /etc/mnttab
148is used.
63aa9df0
MK
1494.4BSD and Digital Unix have a routine \fBgetmntinfo\fP(),
150a wrapper around the system call \fBgetfsstat\fP().
fea681da
MK
151.SH "SEE ALSO"
152.BR fopen (3),
153.BR fstab (5),
0a90178c 154.BR feature_test_macros (7),
fea681da 155.BR mount (8)