1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" References consulted:
24 .\" Linux libc source code
25 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
27 .\" Modified Sat Jul 24 21:46:57 1993 by Rik Faith (faith@cs.unc.edu)
28 .\" Modified 961109, 031115, aeb
30 .TH GETMNTENT 3 2009-09-15 "" "Linux Programmer's Manual"
32 getmntent, setmntent, addmntent, endmntent, hasmntopt,
33 getmntent_r \- get file system descriptor file entry
37 .B #include <mntent.h>
39 .BI "FILE *setmntent(const char *" filename ", const char *" type );
41 .BI "struct mntent *getmntent(FILE *" fp );
43 .BI "int addmntent(FILE *" fp ", const struct mntent *" mnt );
45 .BI "int endmntent(FILE *" fp );
47 .BI "char *hasmntopt(const struct mntent *" mnt ", const char *" opt );
50 .B #include <mntent.h>
52 .BI "struct mntent *getmntent_r(FILE *" fp ", struct mntent *" mntbuf ,
53 .BI " char *" buf ", int " buflen );
57 Feature Test Macro Requirements for glibc (see
58 .BR feature_test_macros (7)):
62 _BSD_SOURCE || _SVID_SOURCE
64 These routines are used to access the file system description file
65 \fI/etc/fstab\fP and the mounted file system description file
70 function opens the file system description file
71 \fIfilename\fP and returns a file pointer which can be used by
73 The argument \fItype\fP is the type of access
74 required and can take the same values as the \fImode\fP argument of
79 function reads the next line from the file system
80 description file \fIfp\fP and returns a pointer to a structure
81 containing the broken out fields from a line in the file.
83 points to a static area of memory which is overwritten by subsequent
91 structure \fImnt\fP to
92 the end of the open file \fIfp\fP.
96 function closes the file system description file
101 function scans the \fImnt_opts\fP field (see below)
104 structure \fImnt\fP for a substring that matches \fIopt\fP.
105 See \fI<mntent.h>\fP and
107 for valid mount options.
111 function is similar to
113 but stores the \fIstruct mount\fP in the provided
115 and stores the strings pointed to by the entries in that struct
116 in the provided array
121 The \fImntent\fP structure is defined in \fI<mntent.h>\fP as follows:
126 char *mnt_fsname; /* name of mounted file system */
127 char *mnt_dir; /* file system path prefix */
128 char *mnt_type; /* mount type (see mntent.h) */
129 char *mnt_opts; /* mount options (see mntent.h) */
130 int mnt_freq; /* dump frequency in days */
131 int mnt_passno; /* pass number on parallel fsck */
136 Since fields in the mtab and fstab files are separated by whitespace,
137 octal escapes are used to represent the four characters space (\e040),
138 tab (\e011), newline (\e012) and backslash (\e134) in those files
139 when they occur in one of the four strings in a
147 from string representation to escaped representation and back.
156 structure or NULL on failure.
160 function returns 0 on success and 1 on failure.
164 function always returns 1.
168 function returns the address of the substring if
169 a match is found and NULL otherwise.
172 /etc/fstab file system description file
173 /etc/mtab mounted file system description file
176 The nonreentrant functions are from SunOS 4.1.3.
179 was introduced in HP-UX 10, but it returns an int.
180 The prototype shown above is glibc-only.
184 function but the calling sequence
185 differs, and the returned structure is different.
189 4.4BSD and Digital Unix have a routine
191 a wrapper around the system call