]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) |
2 | .\" | |
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. | |
6 | .\" | |
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. | |
c13182ef | 11 | .\" |
fea681da MK |
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 | |
18 | .\" professionally. | |
c13182ef | 19 | .\" |
fea681da MK |
20 | .\" Formatted or processed versions of this manual, if unaccompanied by |
21 | .\" the source, must acknowledge the copyright and authors of this work. | |
22 | .\" | |
23 | .\" References consulted: | |
24 | .\" Linux libc source code | |
25 | .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) | |
26 | .\" 386BSD man pages | |
27 | .\" Modified Sat Jul 24 21:46:57 1993 by Rik Faith (faith@cs.unc.edu) | |
28 | .\" Modified 961109, 031115, aeb | |
29 | .\" | |
cc4615cc | 30 | .TH GETMNTENT 3 2007-07-26 "" "Linux Programmer's Manual" |
fea681da MK |
31 | .SH NAME |
32 | getmntent, setmntent, addmntent, endmntent, hasmntopt, | |
33 | getmntent_r \- get file system descriptor file entry | |
34 | .SH SYNOPSIS | |
35 | .nf | |
36 | .B #include <stdio.h> | |
37 | .B #include <mntent.h> | |
38 | .sp | |
39 | .BI "FILE *setmntent(const char *" filename ", const char *" type ); | |
40 | .sp | |
41 | .BI "struct mntent *getmntent(FILE *" fp ); | |
42 | .sp | |
43 | .BI "int addmntent(FILE *" fp ", const struct mntent *" mnt ); | |
44 | .sp | |
45 | .BI "int endmntent(FILE *" fp ); | |
46 | .sp | |
47 | .BI "char *hasmntopt(const struct mntent *" mnt ", const char *" opt ); | |
48 | .sp | |
49 | /* GNU extension */ | |
fea681da MK |
50 | .B #include <mntent.h> |
51 | .sp | |
52 | .BI "struct mntent *getmntent_r(FILE *" fp ", struct mntent *" mntbuf , | |
53 | .BI " char *" buf ", int " buflen ); | |
54 | .fi | |
cc4615cc MK |
55 | .sp |
56 | .in -4n | |
57 | Feature Test Macro Requirements for glibc (see | |
58 | .BR feature_test_macros (7)): | |
59 | .in | |
60 | .sp | |
61 | .BR gemntent_r (): | |
62 | _BSD_SOURCE || _SVID_SOURCE | |
fea681da | 63 | .SH DESCRIPTION |
c13182ef | 64 | These routines are used to access the file system description file |
fea681da MK |
65 | \fI/etc/fstab\fP and the mounted file system description file |
66 | \fI/etc/mtab\fP. | |
67 | .PP | |
60a90ecd MK |
68 | The |
69 | .BR setmntent () | |
70 | function opens the file system description file | |
fea681da | 71 | \fIfp\fP and returns a file pointer which can be used by |
60a90ecd | 72 | .BR getmntent (). |
c13182ef MK |
73 | The argument \fItype\fP is the type of access |
74 | required and can take the same values as the \fImode\fP argument of | |
fea681da MK |
75 | .BR fopen (3). |
76 | .PP | |
60a90ecd MK |
77 | The |
78 | .BR getmntent () | |
79 | function reads the next line from the file system | |
fea681da | 80 | description file \fIfp\fP and returns a pointer to a structure |
c13182ef MK |
81 | containing the broken out fields from a line in the file. |
82 | The pointer | |
fea681da | 83 | points to a static area of memory which is overwritten by subsequent |
60a90ecd MK |
84 | calls to |
85 | .BR getmntent (). | |
fea681da | 86 | .PP |
60a90ecd MK |
87 | The |
88 | .BR addmntent () | |
89 | function adds the mntent structure \fImnt\fP to | |
fea681da MK |
90 | the end of the open file \fIfp\fP. |
91 | .PP | |
60a90ecd MK |
92 | The |
93 | .BR endmntent () | |
94 | function closes the file system description file | |
fea681da MK |
95 | \fIfp\fP. |
96 | .PP | |
60a90ecd MK |
97 | The |
98 | .BR hasmntopt () | |
99 | function scans the \fImnt_opts\fP field (see below) | |
fea681da MK |
100 | of the mntent structure \fImnt\fP for a substring that matches \fIopt\fP. |
101 | See \fI<mntent.h>\fP and | |
102 | .BR mount (8) | |
103 | for valid mount options. | |
104 | .PP | |
60a90ecd MK |
105 | The reentrant |
106 | .BR getmntent_r () | |
107 | function is similar to | |
108 | .BR getmntent (), | |
0c2ec4f1 | 109 | but stores the \fIstruct mount\fP in the provided |
fea681da MK |
110 | .RI * mntbuf |
111 | and stores the strings pointed to by the entries in that struct | |
112 | in the provided array | |
113 | .I buf | |
114 | of size | |
115 | .IR buflen . | |
116 | .PP | |
117 | The \fImntent\fP structure is defined in \fI<mntent.h>\fP as follows: | |
118 | .sp | |
7295b7ed | 119 | .in +0.5i |
fea681da | 120 | .nf |
fea681da | 121 | struct mntent { |
7295b7ed MK |
122 | char *mnt_fsname; /* name of mounted file system */ |
123 | char *mnt_dir; /* file system path prefix */ | |
124 | char *mnt_type; /* mount type (see mntent.h) */ | |
125 | char *mnt_opts; /* mount options (see mntent.h) */ | |
126 | int mnt_freq; /* dump frequency in days */ | |
127 | int mnt_passno; /* pass number on parallel fsck */ | |
fea681da | 128 | }; |
fea681da | 129 | .fi |
7295b7ed | 130 | .in -0.5i |
fea681da MK |
131 | |
132 | Since fields in the mtab and fstab files are separated by whitespace, | |
133 | octal escapes are used to represent the four characters space (\e040), | |
134 | tab (\e011), newline (\e012) and backslash (\e134) in those files | |
135 | when they occur in one of the four strings in a mntent structure. | |
60a90ecd MK |
136 | The routines |
137 | .BR addmntent () | |
138 | and | |
139 | .BR getmntent () | |
140 | will convert | |
fea681da MK |
141 | from string representation to escaped representation and back. |
142 | .SH "RETURN VALUE" | |
60a90ecd MK |
143 | The |
144 | .BR getmntent () | |
145 | and | |
146 | .BR getmntent_r () | |
147 | functions return | |
fea681da MK |
148 | a pointer to the mntent structure or NULL on failure. |
149 | .PP | |
60a90ecd MK |
150 | The |
151 | .BR addmntent () | |
152 | function returns 0 on success and 1 on failure. | |
fea681da | 153 | .PP |
60a90ecd MK |
154 | The |
155 | .BR endmntent () | |
156 | function always returns 1. | |
fea681da | 157 | .PP |
60a90ecd MK |
158 | The |
159 | .BR hasmntopt () | |
160 | function returns the address of the substring if | |
fea681da MK |
161 | a match is found and NULL otherwise. |
162 | .SH FILES | |
163 | .nf | |
164 | /etc/fstab file system description file | |
165 | /etc/mtab mounted file system description file | |
166 | .fi | |
167 | .SH "CONFORMING TO" | |
168 | The non-reentrant functions are from SunOS 4.1.3. | |
169 | A routine | |
63aa9df0 | 170 | .BR getmntent_r () |
c13182ef | 171 | was introduced in HP-UX 10, but it returns an int. |
68e1685c | 172 | The prototype shown above is glibc-only. |
fea681da | 173 | LSB deprecates the functions |
63aa9df0 MK |
174 | .BR endhostent (), |
175 | .BR sethostent () | |
fea681da | 176 | and |
63aa9df0 | 177 | .BR setmntent (). |
fea681da | 178 | .SH NOTES |
60a90ecd MK |
179 | System V also has a |
180 | .BR getmntent () | |
181 | function but the calling sequence | |
c13182ef MK |
182 | differs, and the returned structure is different. |
183 | Under System V | |
fea681da MK |
184 | .I /etc/mnttab |
185 | is used. | |
60a90ecd MK |
186 | 4.4BSD and Digital Unix have a routine |
187 | .BR getmntinfo (), | |
188 | a wrapper around the system call | |
189 | .BR getfsstat (). | |
fea681da MK |
190 | .SH "SEE ALSO" |
191 | .BR fopen (3), | |
192 | .BR fstab (5), | |
193 | .BR mount (8) |