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 (date) "Linux man-pages (unreleased)"
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
133 and stores the strings pointed to by the entries in that structure
134 in the provided array
141 structure is defined in
148 char *mnt_fsname; /* name of mounted filesystem */
149 char *mnt_dir; /* filesystem path prefix */
150 char *mnt_type; /* mount type (see mntent.h) */
151 char *mnt_opts; /* mount options (see mntent.h) */
152 int mnt_freq; /* dump frequency in days */
153 int mnt_passno; /* pass number on parallel fsck */
158 Since fields in the mtab and fstab files are separated by whitespace,
159 octal escapes are used to represent the characters space (\e040),
160 tab (\e011), newline (\e012), and backslash (\e\e) in those files
161 when they occur in one of the four strings in a
169 from string representation to escaped representation and back.
170 When converting from escaped representation, the sequence \e134 is
171 also converted to a backslash.
180 structure or NULL on failure.
184 function returns 0 on success and 1 on failure.
188 function always returns 1.
192 function returns the address of the substring if
193 a match is found and NULL otherwise.
197 filesystem description file
200 mounted filesystem description file
202 For an explanation of the terms used in this section, see
210 Interface Attribute Value
215 T} Thread safety MT-Safe
219 MT-Unsafe race:mntentbuf locale
224 MT-Safe race:stream locale
228 T} Thread safety MT-Safe locale
234 The nonreentrant functions are from SunOS 4.1.3.
237 was introduced in HP-UX 10, but it returns an
239 The prototype shown above is glibc-only.
243 function but the calling sequence
244 differs, and the returned structure is different.
248 4.4BSD and Digital UNIX have a routine
250 a wrapper around the system call