2 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\" References consulted:
7 .\" Linux libc source code
8 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
10 .\" Modified Sat Jul 24 21:46:57 1993 by Rik Faith (faith@cs.unc.edu)
11 .\" Modified 961109, 031115, aeb
13 .TH getmntent 3 (date) "Linux man-pages (unreleased)"
15 getmntent, setmntent, addmntent, endmntent, hasmntopt,
16 getmntent_r \- get filesystem descriptor file entry
19 .RI ( libc ", " \-lc )
23 .B #include <mntent.h>
25 .BI "FILE *setmntent(const char *" filename ", const char *" type );
27 .BI "struct mntent *getmntent(FILE *" stream );
29 .BI "int addmntent(FILE *restrict " stream ,
30 .BI " const struct mntent *restrict " mnt );
32 .BI "int endmntent(FILE *" streamp );
34 .BI "char *hasmntopt(const struct mntent *" mnt ", const char *" opt );
37 .B #include <mntent.h>
39 .BI "struct mntent *getmntent_r(FILE *restrict " streamp ,
40 .BI " struct mntent *restrict " mntbuf ,
41 .BI " char " buf "[restrict ." buflen "], int " buflen );
45 Feature Test Macro Requirements for glibc (see
46 .BR feature_test_macros (7)):
53 glibc 2.19 and earlier:
54 _BSD_SOURCE || _SVID_SOURCE
57 These routines are used to access the filesystem description file
59 and the mounted filesystem description file
64 function opens the filesystem description file
66 and returns a file pointer which can be used by
71 required and can take the same values as the
75 The returned stream should be closed using
82 function reads the next line of the filesystem
85 and returns a pointer to a structure
86 containing the broken out fields from a line in the file.
88 points to a static area of memory which is overwritten by subsequent
106 associated with the filesystem description file.
117 for a substring that matches
123 for valid mount options.
127 function is similar to
134 and stores the strings pointed to by the entries in that structure
135 in the provided array
142 structure is defined in
149 char *mnt_fsname; /* name of mounted filesystem */
150 char *mnt_dir; /* filesystem path prefix */
151 char *mnt_type; /* mount type (see mntent.h) */
152 char *mnt_opts; /* mount options (see mntent.h) */
153 int mnt_freq; /* dump frequency in days */
154 int mnt_passno; /* pass number on parallel fsck */
159 Since fields in the mtab and fstab files are separated by whitespace,
160 octal escapes are used to represent the characters space (\e040),
161 tab (\e011), newline (\e012), and backslash (\e\e) in those files
162 when they occur in one of the four strings in a
170 from string representation to escaped representation and back.
171 When converting from escaped representation, the sequence \e134 is
172 also converted to a backslash.
181 structure or NULL on failure.
185 function returns 0 on success and 1 on failure.
189 function always returns 1.
193 function returns the address of the substring if
194 a match is found and NULL otherwise.
198 filesystem description file
201 mounted filesystem description file
203 For an explanation of the terms used in this section, see
209 Interface Attribute Value
216 T} Thread safety MT-Safe
224 MT-Unsafe race:mntentbuf locale
233 MT-Safe race:stream locale
239 T} Thread safety MT-Safe locale
244 The nonreentrant functions are from SunOS 4.1.3.
247 was introduced in HP-UX 10, but it returns an
249 The prototype shown above is glibc-only.
253 function but the calling sequence
254 differs, and the returned structure is different.
258 4.4BSD and Digital UNIX have a routine
260 a wrapper around the system call