]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/getmntent.3
dlopen.3: Clarify that constructors are called only when library is first loaded
[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.\"
9ba01802 32.TH GETMNTENT 3 2019-03-06 "" "Linux Programmer's Manual"
fea681da
MK
33.SH NAME
34getmntent, setmntent, addmntent, endmntent, hasmntopt,
9ee4a2b6 35getmntent_r \- get filesystem descriptor file entry
fea681da
MK
36.SH SYNOPSIS
37.nf
38.B #include <stdio.h>
39.B #include <mntent.h>
68e4db0a 40.PP
fea681da 41.BI "FILE *setmntent(const char *" filename ", const char *" type );
68e4db0a 42.PP
7de6ef86 43.BI "struct mntent *getmntent(FILE *" stream );
68e4db0a 44.PP
7de6ef86 45.BI "int addmntent(FILE *" stream ", const struct mntent *" mnt );
68e4db0a 46.PP
7de6ef86 47.BI "int endmntent(FILE *" streamp );
68e4db0a 48.PP
fea681da 49.BI "char *hasmntopt(const struct mntent *" mnt ", const char *" opt );
f90f031e 50
fea681da 51/* GNU extension */
fea681da 52.B #include <mntent.h>
68e4db0a 53.PP
7de6ef86 54.BI "struct mntent *getmntent_r(FILE *" streamp ", struct mntent *" mntbuf ,
fea681da
MK
55.BI " char *" buf ", int " buflen );
56.fi
68e4db0a 57.PP
cc4615cc
MK
58.in -4n
59Feature Test Macro Requirements for glibc (see
60.BR feature_test_macros (7)):
61.in
68e4db0a 62.PP
cd74b428 63.BR getmntent_r ():
51c612fb
MK
64 Since glibc 2.19:
65 _DEFAULT_SOURCE
66 Glibc 2.19 and earlier:
67 _BSD_SOURCE || _SVID_SOURCE
fea681da 68.SH DESCRIPTION
9ee4a2b6 69These routines are used to access the filesystem description file
c6fa0841 70.I /etc/fstab
9ee4a2b6 71and the mounted filesystem description file
e6c6110c 72.IR /etc/mtab .
fea681da 73.PP
60a90ecd
MK
74The
75.BR setmntent ()
9ee4a2b6 76function opens the filesystem description file
c6fa0841
MK
77.I filename
78and returns a file pointer which can be used by
60a90ecd 79.BR getmntent ().
c6fa0841
MK
80The argument
81.I type
82is the type of access
83required and can take the same values as the
84.I mode
85argument of
fea681da 86.BR fopen (3).
7c2c86ef
EH
87The returned stream should be closed using
88.BR endmntent ()
89rather than
90.BR fclose (3).
fea681da 91.PP
60a90ecd
MK
92The
93.BR getmntent ()
7de6ef86
CD
94function reads the next line of the filesystem
95description file from
96.I stream
c6fa0841 97and returns a pointer to a structure
c13182ef
MK
98containing the broken out fields from a line in the file.
99The pointer
fea681da 100points to a static area of memory which is overwritten by subsequent
60a90ecd
MK
101calls to
102.BR getmntent ().
fea681da 103.PP
60a90ecd
MK
104The
105.BR addmntent ()
c3022783
MK
106function adds the
107.I mntent
c6fa0841
MK
108structure
109.I mnt
110to
7de6ef86
CD
111the end of the open
112.IR stream .
fea681da 113.PP
60a90ecd
MK
114The
115.BR endmntent ()
7de6ef86
CD
116function closes the
117.IR stream
118associated with the filesystem description file.
fea681da 119.PP
60a90ecd
MK
120The
121.BR hasmntopt ()
c6fa0841
MK
122function scans the
123.I mnt_opts
124field (see below)
c3022783
MK
125of the
126.I mntent
c6fa0841
MK
127structure
128.I mnt
129for a substring that matches
130.IR opt .
131See
132.I <mntent.h>
133and
fea681da
MK
134.BR mount (8)
135for valid mount options.
136.PP
60a90ecd
MK
137The reentrant
138.BR getmntent_r ()
139function is similar to
140.BR getmntent (),
c6fa0841
MK
141but stores the
142.IR "struct mount"
143in the provided
bd9b2a9c 144.I *mntbuf
fea681da
MK
145and stores the strings pointed to by the entries in that struct
146in the provided array
147.I buf
148of size
149.IR buflen .
150.PP
c6fa0841
MK
151The
152.I mntent
153structure is defined in
154.I <mntent.h>
155as follows:
51f5698d 156.PP
a08ea57c 157.in +4n
b8302363 158.EX
fea681da 159struct mntent {
9ee4a2b6
MK
160 char *mnt_fsname; /* name of mounted filesystem */
161 char *mnt_dir; /* filesystem path prefix */
7295b7ed
MK
162 char *mnt_type; /* mount type (see mntent.h) */
163 char *mnt_opts; /* mount options (see mntent.h) */
164 int mnt_freq; /* dump frequency in days */
165 int mnt_passno; /* pass number on parallel fsck */
fea681da 166};
b8302363 167.EE
a08ea57c 168.in
847e0d88 169.PP
fea681da 170Since fields in the mtab and fstab files are separated by whitespace,
ad56cef4
MK
171octal escapes are used to represent the characters space (\e040),
172tab (\e011), newline (\e012), and backslash (\e\e) in those files
c3022783
MK
173when they occur in one of the four strings in a
174.I mntent
175structure.
60a90ecd
MK
176The routines
177.BR addmntent ()
178and
179.BR getmntent ()
180will convert
fea681da 181from string representation to escaped representation and back.
ad56cef4
MK
182When converting from escaped representation, the sequence \e134 is
183also converted to a backslash.
47297adb 184.SH RETURN VALUE
60a90ecd
MK
185The
186.BR getmntent ()
187and
188.BR getmntent_r ()
189functions return
c3022783
MK
190a pointer to the
191.I mntent
192structure or NULL on failure.
fea681da 193.PP
60a90ecd
MK
194The
195.BR addmntent ()
196function returns 0 on success and 1 on failure.
fea681da 197.PP
60a90ecd
MK
198The
199.BR endmntent ()
200function always returns 1.
fea681da 201.PP
60a90ecd
MK
202The
203.BR hasmntopt ()
204function returns the address of the substring if
fea681da
MK
205a match is found and NULL otherwise.
206.SH FILES
d0b8a8d8
MK
207.TP
208.I /etc/fstab
209filesystem description file
210.TP
211.I /etc/mtab
212mounted filesystem description file
b7a0a144
ZL
213.SH ATTRIBUTES
214For an explanation of the terms used in this section, see
215.BR attributes (7).
74714ea8 216.ad l
b7a0a144
ZL
217.TS
218allbox;
219lbw13 lb lbw31
220l l l.
221Interface Attribute Value
222T{
223.BR setmntent (),
224.BR endmntent (),
225.BR hasmntopt ()
226T} Thread safety MT-Safe
227T{
228.BR getmntent ()
229T} Thread safety MT-Unsafe race:mntentbuf locale
230T{
231.BR addmntent ()
232T} Thread safety MT-Safe race:stream locale
233T{
234.BR getmntent_r ()
235T} Thread safety MT-Safe locale
236.TE
74714ea8 237.ad
47297adb 238.SH CONFORMING TO
54d75d6c 239The nonreentrant functions are from SunOS 4.1.3.
fea681da 240A routine
63aa9df0 241.BR getmntent_r ()
c13182ef 242was introduced in HP-UX 10, but it returns an int.
68e1685c 243The prototype shown above is glibc-only.
fea681da 244.SH NOTES
60a90ecd
MK
245System V also has a
246.BR getmntent ()
247function but the calling sequence
c13182ef
MK
248differs, and the returned structure is different.
249Under System V
fea681da
MK
250.I /etc/mnttab
251is used.
008f1ecc 2524.4BSD and Digital UNIX have a routine
60a90ecd
MK
253.BR getmntinfo (),
254a wrapper around the system call
255.BR getfsstat ().
47297adb 256.SH SEE ALSO
fea681da
MK
257.BR fopen (3),
258.BR fstab (5),
259.BR mount (8)