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