1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\" References consulted:
6 .\" Linux libc source code
7 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
9 .\" Modified Sat Jul 24 21:46:57 1993 by Rik Faith (faith@cs.unc.edu)
10 .\" Modified 961109, 031115, aeb
12 .TH GETMNTENT 3 2021-03-22 "" "Linux Programmer's Manual"
14 getmntent, setmntent, addmntent, endmntent, hasmntopt,
15 getmntent_r \- get filesystem descriptor file entry
18 .RI ( libc ", " \-lc )
22 .B #include <mntent.h>
24 .BI "FILE *setmntent(const char *" filename ", const char *" type );
26 .BI "struct mntent *getmntent(FILE *" stream );
28 .BI "int addmntent(FILE *restrict " stream ,
29 .BI " const struct mntent *restrict " mnt );
31 .BI "int endmntent(FILE *" streamp );
33 .BI "char *hasmntopt(const struct mntent *" mnt ", const char *" opt );
36 .B #include <mntent.h>
38 .BI "struct mntent *getmntent_r(FILE *restrict " streamp ,
39 .BI " struct mntent *restrict " mntbuf ,
40 .BI " char *restrict " buf ", int " buflen );
44 Feature Test Macro Requirements for glibc (see
45 .BR feature_test_macros (7)):
52 Glibc 2.19 and earlier:
53 _BSD_SOURCE || _SVID_SOURCE
56 These routines are used to access the filesystem description file
58 and the mounted filesystem description file
63 function opens the filesystem description file
65 and returns a file pointer which can be used by
70 required and can take the same values as the
74 The returned stream should be closed using
81 function reads the next line of the filesystem
84 and returns a pointer to a structure
85 containing the broken out fields from a line in the file.
87 points to a static area of memory which is overwritten by subsequent
105 associated with the filesystem description file.
116 for a substring that matches
122 for valid mount options.
126 function is similar to
132 and stores the strings pointed to by the entries in that struct
133 in the provided array
140 structure is defined in
147 char *mnt_fsname; /* name of mounted filesystem */
148 char *mnt_dir; /* filesystem path prefix */
149 char *mnt_type; /* mount type (see mntent.h) */
150 char *mnt_opts; /* mount options (see mntent.h) */
151 int mnt_freq; /* dump frequency in days */
152 int mnt_passno; /* pass number on parallel fsck */
157 Since fields in the mtab and fstab files are separated by whitespace,
158 octal escapes are used to represent the characters space (\e040),
159 tab (\e011), newline (\e012), and backslash (\e\e) in those files
160 when they occur in one of the four strings in a
168 from string representation to escaped representation and back.
169 When converting from escaped representation, the sequence \e134 is
170 also converted to a backslash.
179 structure or NULL on failure.
183 function returns 0 on success and 1 on failure.
187 function always returns 1.
191 function returns the address of the substring if
192 a match is found and NULL otherwise.
196 filesystem description file
199 mounted filesystem description file
201 For an explanation of the terms used in this section, see
209 Interface Attribute Value
214 T} Thread safety MT-Safe
218 MT-Unsafe race:mntentbuf locale
223 MT-Safe race:stream locale
227 T} Thread safety MT-Safe locale
233 The nonreentrant functions are from SunOS 4.1.3.
236 was introduced in HP-UX 10, but it returns an
238 The prototype shown above is glibc-only.
242 function but the calling sequence
243 differs, and the returned structure is different.
247 4.4BSD and Digital UNIX have a routine
249 a wrapper around the system call