OSDN Git Service

f14118c20729c8ffa2dcdb629ac25d5730c2ce8c
[linuxjm/LDP_man-pages.git] / draft / man3 / getmntent.3
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.
11 .\"
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.
19 .\"
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 .\"
30 .\" Japanese Version Copyright (c) 1998 NAKANO Takeo all rights reserved.
31 .\" Translated 1998-03-01, NAKANO Takeo <nakano@apm.seikei.ac.jp>
32 .\" Updated 2000-09-03, Kentaro Shirakata <argrath@ub32.org>
33 .\" Updated 2005-03-18, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
34 .\"
35 .TH GETMNTENT 3  2009-09-15 "" "Linux Programmer's Manual"
36 .\"O .SH NAME
37 .\"O getmntent, setmntent, addmntent, endmntent, hasmntopt,
38 .\"O getmntent_r \- get file system descriptor file entry
39 .SH Ì¾Á°
40 getmntent, setmntent, addmntent, endmntent, hasmntopt,
41 getmntent_r \- ¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥àµ­½Ò¥Õ¥¡¥¤¥ë¤Î¥¨¥ó¥È¥ê¤ò¼èÆÀ¤¹¤ë
42 .\"O .SH SYNOPSIS
43 .SH ½ñ¼°
44 .nf
45 .B #include <stdio.h>
46 .B #include <mntent.h>
47 .sp
48 .BI "FILE *setmntent(const char *" filename ", const char *" type );
49 .sp
50 .BI "struct mntent *getmntent(FILE *" fp );
51 .sp
52 .BI "int addmntent(FILE *" fp ", const struct mntent *" mnt );
53 .sp
54 .BI "int endmntent(FILE *" fp );
55 .sp
56 .BI "char *hasmntopt(const struct mntent *" mnt ", const char *" opt );
57 .sp
58 .\"O /* GNU extension */
59 /* GNU ¤Ë¤è¤ë³ÈÄ¥ */
60 .B #include <mntent.h>
61 .sp
62 .BI "struct mntent *getmntent_r(FILE *" fp ", struct mntent *" mntbuf ,
63 .BI "                           char *" buf ", int " buflen );
64 .fi
65 .sp
66 .in -4n
67 .\"O Feature Test Macro Requirements for glibc (see
68 .\"O .BR feature_test_macros (7)):
69 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
70 .RB ( feature_test_macros (7)
71 »²¾È):
72 .in
73 .sp
74 .BR getmntent_r ():
75 _BSD_SOURCE || _SVID_SOURCE
76 .\"O .SH DESCRIPTION
77 .SH ÀâÌÀ
78 .\"O These routines are used to access the file system description file
79 .\"O \fI/etc/fstab\fP and the mounted file system description file
80 .\"O \fI/etc/mtab\fP.
81 ¤³¤ì¤é¤Î¥ë¡¼¥Á¥ó¤Ï¡¢¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤òµ­½Ò¤·¤¿¥Õ¥¡¥¤¥ë \fI/etc/fstab\fP
82 ¤È¡¢¥Þ¥¦¥ó¥È¤µ¤ì¤Æ¤¤¤ë¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤òµ­½Ò¤·¤¿¥Õ¥¡¥¤¥ë
83 \fI/etc/mtab\fP ¤Ë¥¢¥¯¥»¥¹¤¹¤ë¤¿¤á¤ËÍѤ¤¤é¤ì¤ë¡£
84 .PP
85 .\"O The
86 .\"O .BR setmntent ()
87 .\"O function opens the file system description file
88 .\"O \fIfilename\fP and returns a file pointer which can be used by
89 .\"O .BR getmntent ().
90 .\"O The argument \fItype\fP is the type of access
91 .\"O required and can take the same values as the \fImode\fP argument of
92 .\"O .BR fopen (3).
93 .BR setmntent ()
94 ´Ø¿ô¤Ï¡¢¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤Îµ­½Ò¥Õ¥¡¥¤¥ë \fIfilename\fP ¤ò¥ª¡¼¥×¥ó¤·¤Æ¡¢
95 ¤½¤Î¥Õ¥¡¥¤¥ë¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£¤³¤Î¥Õ¥¡¥¤¥ë¥Ý¥¤¥ó¥¿¤Ï
96 .BR getmntent ()
97 ¤Ë¤è¤Ã¤ÆÍѤ¤¤é¤ì¤ë¡£°ú¤­¿ô \fItype\fP ¤ÏÍ׵᤹¤ë¥¢¥¯¥»¥¹·Á¼°¤Ç¡¢
98 .BR fopen (3)
99 ¤Î \fImode\fP °ú¤­¿ô¤ÈƱ¤¸Ãͤò¼è¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
100 .PP
101 .\"O The
102 .\"O .BR getmntent ()
103 .\"O function reads the next line from the file system
104 .\"O description file \fIfp\fP and returns a pointer to a structure
105 .\"O containing the broken out fields from a line in the file.
106 .\"O The pointer
107 .\"O points to a static area of memory which is overwritten by subsequent
108 .\"O calls to
109 .\"O .BR getmntent ().
110 .BR getmntent ()
111 ´Ø¿ô¤Ï¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤Îµ­½Ò¥Õ¥¡¥¤¥ë \fIfp\fP ¤«¤é¿·¤·¤¤¹Ô¤òÆÉ
112 ¤ß¹þ¤ß¡¢¹Ô¤ò¥Õ¥£¡¼¥ë¥É¤Ëʬ³ä¤·¤¿ÆâÍƤò¼ý¤á¤¿¹½Â¤ÂΤؤΥݥ¤¥ó¥¿¤òÊÖ¤¹¡£
113 ¥Ý¥¤¥ó¥¿¤Ï¥á¥â¥ê¤ÎÀÅŪ¤ÊÎΰè¤ò»Ø¤·¤Æ¤ª¤ê¡¢¤³¤ÎÎΰè¤Ï
114 .BR getmntent ()
115 ¤ò¼¡¤Ë¸Æ¤Ó½Ð¤·¤¿¤È¤­¤Ë¾å½ñ¤­¤µ¤ì¤Æ¤·¤Þ¤¦¡£
116 .PP
117 .\"O The
118 .\"O .BR addmntent ()
119 .\"O function adds the
120 .\"O .I mntent
121 .\"O structure \fImnt\fP to
122 .\"O the end of the open file \fIfp\fP.
123 .BR addmntent ()
124 ´Ø¿ô¤Ï
125 .I mntent
126 ¹½Â¤ÂΠ\fImnt\fP ¤ÎÆâÍƤò¡¢¥ª¡¼¥×¥ó¤µ¤ì¤Æ¤¤¤ë¥Õ¥¡¥¤¥ë
127 \fIfp\fP ¤ÎºÇ¸å¤ËÄɲ乤롣
128 .PP
129 .\"O The
130 .\"O .BR endmntent ()
131 .\"O function closes the file system description file
132 .\"O \fIfp\fP.
133 .BR endmntent ()
134 ´Ø¿ô¤Ï¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤Îµ­½Ò¥Õ¥¡¥¤¥ë \fIfp\fP ¤òÊĤ¸¤ë¡£
135 .PP
136 .\"O The
137 .\"O .BR hasmntopt ()
138 .\"O function scans the \fImnt_opts\fP field (see below)
139 .\"O of the
140 .\"O .I mntent
141 .\"O structure \fImnt\fP for a substring that matches \fIopt\fP.
142 .\"O See \fI<mntent.h>\fP and
143 .\"O .BR mount (8)
144 .\"O for valid mount options.
145 .BR hasmntopt ()
146 ´Ø¿ô¤Ï
147 .I mntent
148 ¹½Â¤ÂΠ\fImnt\fP ¤Î \fImnt_opts\fP ¥Õ¥£¡¼¥ë¥É (²¼µ­
149 »²¾È) ¤ò¥¹¥­¥ã¥ó¤·¡¢ \fIopt\fP ¤Ë°ìÃפ¹¤ëÉôʬʸ»úÎ󤬤¢¤ë¤«¤òÄ´¤Ù¤ë¡£
150 Í­¸ú¤Ê¥Þ¥¦¥ó¥È¥ª¥×¥·¥ç¥ó¤Ë¤Ä¤¤¤Æ¤Ï \fI<mntent.h>\fP ¤È
151 .BR mount (8)
152 ¤ò»²¾È¤Î¤³¤È¡£
153 .PP
154 .\"O The reentrant \fBgetmntent_r\fP() function is similar to
155 .\"O .BR getmntent (),
156 .\"O but stores the \fIstruct mount\fP in the provided
157 .\"O .I *mntbuf
158 .\"O and stores the strings pointed to by the entries in that struct
159 .\"O in the provided array
160 .\"O .I buf
161 .\"O of size
162 .\"O .IR buflen .
163 ¥ê¥¨¥ó¥È¥é¥ó¥È¤Ê´Ø¿ô
164 .BR getmntent_r ()
165 ¤Ï
166 .BR getmntent ()
167 ¤ÈƱ¤¸¤À¤¬¡¢
168 ¥æ¡¼¥¶¤¬ÍÑ°Õ¤·¤¿
169 .I *mntbuf
170 ¤Ë \fIstruct mount\fP ¤ò³ÊǼ¤·¡¢¤½¤Î¹½Â¤ÂΤγƥ¨¥ó¥È¥ê¤¬»Ø¤·¼¨¤¹Ê¸»úÎó¤ò
171 ¥æ¡¼¥¶¤¬ÍÑ°Õ¤·¤¿Â礭¤µ
172 .I buflen
173 ¤ÎÇÛÎó
174 .I buf
175 ¤Ë½ñ¤­¹þ¤à¡£
176
177 .PP
178 .\"O The \fImntent\fP structure is defined in \fI<mntent.h>\fP as follows:
179 \fImntent\fP ¹½Â¤ÂΤϠ\fI<mntent.h>\fP ¤Ç°Ê²¼¤Î¤è¤¦¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡£
180 .sp
181 .in +4n
182 .nf
183 struct mntent {
184     char *mnt_fsname;   /* name of mounted file system */
185     char *mnt_dir;      /* file system path prefix */
186     char *mnt_type;     /* mount type (see mntent.h) */
187     char *mnt_opts;     /* mount options (see mntent.h) */
188     int   mnt_freq;     /* dump frequency in days */
189     int   mnt_passno;   /* pass number on parallel fsck */
190 };
191 .fi
192 .in
193
194 .\"O Since fields in the mtab and fstab files are separated by whitespace,
195 .\"O octal escapes are used to represent the four characters space (\e040),
196 .\"O tab (\e011), newline (\e012) and backslash (\e134) in those files
197 .\"O when they occur in one of the four strings in a
198 .\"O .I mntent
199 .\"O structure.
200 .\"O The routines
201 .\"O .BR addmntent ()
202 .\"O and
203 .\"O .BR getmntent ()
204 .\"O will convert
205 .\"O from string representation to escaped representation and back.
206 mtab ¤ä fstab ¥Õ¥¡¥¤¥ë¤Ç¤Ï¡¢³Æ¥Õ¥£¡¼¥ë¥É¤Ï¶õÇò¤Ç¶èÀÚ¤é¤ì¤Æ¤¤¤ë¤Î¤Ç¡¢
207 ¥¹¥Ú¡¼¥¹¡¢¥¿¥Ö¡¢²þ¹Ô¡¢¥Ð¥Ã¥¯¥¹¥é¥Ã¥·¥å¤Î 4ʸ»ú¤ò¤³¤ì¤é¤Î¥Õ¥¡¥¤¥ë¤Ç
208 »È¤¤¤¿¤¤¾ì¹ç¤Ç¡¢¤«¤Ä
209 .I mntent
210 ¹½Â¤ÂΤΠ4¤Ä¤Îʸ»úÎó¥á¥ó¥Ð¡¼¤Î¤¤¤º¤ì¤«¤ËÂбþ¤¹¤ë¥Õ¥£¡¼¥ë¥ÉÆâ¤Ç
211 »È¤¤¤¿¤¤¾ì¹ç¤Ë¤Ï¡¢8¿Ê¤Î¥¨¥¹¥±¡¼¥×ɽµ­¤ò»È¤Ã¤Æɽ¸½¤¹¤ë:
212 ¥¹¥Ú¡¼¥¹ (\e040), ¥¿¥Ö (\e011), ²þ¹Ô (\e012), ¥Ð¥Ã¥¯¥¹¥é¥Ã¥·¥å (\e134)¡£
213 .BR addmntent ()
214 ¤È
215 .BR getmntent ()
216 ¤Ï¡¢Ê¸»úÎóɽ¸½¤«¤é
217 ¥¨¥¹¥±¡¼¥×ɽ¸½¤Ø¤ÎÊÑ´¹¡¢¤ª¤è¤Ó¤½¤ÎµÕ¤ò¹Ô¤¦¡£
218 .\"O .SH "RETURN VALUE"
219 .SH ÊÖ¤êÃÍ
220 .\"O The
221 .\"O .BR getmntent ()
222 .\"O and
223 .\"O .BR getmntent_r ()
224 .\"O functions return
225 .\"O a pointer to the
226 .\"O .I mntent
227 .\"O structure or NULL on failure.
228 .BR getmntent ()
229 ¤È
230 .BR getmntent_r ()
231 ¤Ï
232 .I mntent
233 ¹½Â¤ÂΤؤΥݥ¤¥ó¥¿¤òÊÖ¤¹¡£
234 ¼ºÇÔ¤·¤¿¾ì¹ç¤Ï NULL ¤òÊÖ¤¹¡£
235 .PP
236 .\"O The
237 .\"O .BR addmntent ()
238 .\"O function returns 0 on success and 1 on failure.
239 .\Baddmntent\fP() ´Ø¿ô¤ÏÀ®¸ù¤·¤¿¤é 0 ¤òÊÖ¤·¡¢¼ºÇÔ¤·¤¿¤é 1 ¤òÊÖ¤¹¡£
240 .PP
241 .\"O The
242 .\"O .BR endmntent ()
243 .\"O function always returns 1.
244 .BR endmntent ()
245 ´Ø¿ô¤Ï¤Ä¤Í¤Ë 1 ¤òÊÖ¤¹¡£
246 .PP
247 .\"O The
248 .\"O .BR hasmntopt ()
249 .\"O function returns the address of the substring if
250 .\"O a match is found and NULL otherwise.
251 .BR hasmntopt ()
252 ´Ø¿ô¤Ï¡¢¥Þ¥Ã¥Á¤·¤¿¾ì¹ç¤ÏÉôʬʸ»úÎó¤Ø¤Î¥¢¥É¥ì¥¹¤òÊÖ¤·¡¢
253 ¥Þ¥Ã¥Á¤·¤Ê¤±¤ì¤Ð NULL ¤òÊÖ¤¹¡£
254 .\"O .SH FILES
255 .SH ¥Õ¥¡¥¤¥ë
256 .nf
257 .\"O /etc/fstab          file system description file
258 .\"O /etc/mtab           mounted file system description file
259 /etc/fstab          ¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥àµ­½Ò¥Õ¥¡¥¤¥ë
260 /etc/mtab           ¥Þ¥¦¥ó¥È¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤Îµ­½Ò¥Õ¥¡¥¤¥ë
261 .fi
262 .\"O .SH "CONFORMING TO"
263 .SH ½àµò
264 .\"O The nonreentrant functions are from SunOS 4.1.3.
265 .\"O A routine
266 .\"O .BR getmntent_r ()
267 .\"O was introduced in HP-UX 10, but it returns an int.
268 .\"O The prototype shown above is glibc-only.
269 ¥ê¥¨¥ó¥È¥é¥ó¥È¤Ç¤Ê¤¤´Ø¿ô¤Ï SunOS 4.1.3 Í³Íè¤Î¤â¤Î¤Ç¤¢¤ë¡£
270 .BR getmntent_r ()
271 ´Ø¿ô¤Ï HPUX 10 ¤ÇƳÆþ¤µ¤ì¤¿¤¬¡¢¤³¤Î¥Ð¡¼¥¸¥ç¥ó¤Ç¤Ï int ¤òÊÖ¤¹¡£
272 ¾åµ­¤Ë¼¨¤·¤¿¥×¥í¥È¥¿¥¤¥×¤Ï glibc Æȼ«¤Î¤â¤Î¤Ç¤¢¤ë¡£
273 .\"O .SH NOTES
274 .SH Ãí°Õ
275 .\"O System V also has a
276 .\"O .BR getmntent ()
277 .\"O function but the calling sequence
278 .\"O differs, and the returned structure is different.
279 .\"O Under System V
280 .\"O .I /etc/mnttab
281 .\"O is used.
282 System V ¤Ë¤â
283 .BR getmntent ()
284 ´Ø¿ô¤Ï¤¢¤ë¤¬¡¢
285 ¸Æ¤Ó½Ð¤·¼ê½ç¤¬°Û¤Ê¤ê¡¢ÊÖ¤µ¤ì¤ë¹½Â¤ÂΤâ°Û¤Ê¤ë¡£
286 System V ¤Ç¤Ï
287 .I /etc/mnttab
288 ¤¬ÍѤ¤¤é¤ì¤ë¡£
289 .\"O 4.4BSD and Digital Unix have a routine
290 .\"O .BR getmntinfo (),
291 .\"O a wrapper around the system call
292 .\"O .BR getfsstat ().
293 4.4BSD ¤È Digital Unix ¤Ë¤Ï
294 .BR getmntinfo ()
295 ¤¬¤¢¤ë¤¬¡¢
296 ¥·¥¹¥Æ¥à¥³¡¼¥ë
297 .BR getfsstat ()
298 ¤Î¥é¥Ã¥Ñ¡¼´Ø¿ô¤Ç¤¢¤ë¡£
299 .\"O .SH "SEE ALSO"
300 .SH ´ØÏ¢¹àÌÜ
301 .BR fopen (3),
302 .BR fstab (5),
303 .BR mount (8)