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 .\" 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>
35 .TH GETMNTENT 3 2009-09-15 "" "Linux Programmer's Manual"
37 .\"O getmntent, setmntent, addmntent, endmntent, hasmntopt,
38 .\"O getmntent_r \- get file system descriptor file entry
40 getmntent, setmntent, addmntent, endmntent, hasmntopt,
41 getmntent_r \- ¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥àµ½Ò¥Õ¥¡¥¤¥ë¤Î¥¨¥ó¥È¥ê¤ò¼èÆÀ¤¹¤ë
46 .B #include <mntent.h>
48 .BI "FILE *setmntent(const char *" filename ", const char *" type );
50 .BI "struct mntent *getmntent(FILE *" fp );
52 .BI "int addmntent(FILE *" fp ", const struct mntent *" mnt );
54 .BI "int endmntent(FILE *" fp );
56 .BI "char *hasmntopt(const struct mntent *" mnt ", const char *" opt );
58 .\"O /* GNU extension */
60 .B #include <mntent.h>
62 .BI "struct mntent *getmntent_r(FILE *" fp ", struct mntent *" mntbuf ,
63 .BI " char *" buf ", int " buflen );
67 .\"O Feature Test Macro Requirements for glibc (see
68 .\"O .BR feature_test_macros (7)):
69 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
70 .RB ( feature_test_macros (7)
75 _BSD_SOURCE || _SVID_SOURCE
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
81 ¤³¤ì¤é¤Î¥ë¡¼¥Á¥ó¤Ï¡¢¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤òµ½Ò¤·¤¿¥Õ¥¡¥¤¥ë \fI/etc/fstab\fP
82 ¤È¡¢¥Þ¥¦¥ó¥È¤µ¤ì¤Æ¤¤¤ë¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤òµ½Ò¤·¤¿¥Õ¥¡¥¤¥ë
83 \fI/etc/mtab\fP ¤Ë¥¢¥¯¥»¥¹¤¹¤ë¤¿¤á¤ËÍѤ¤¤é¤ì¤ë¡£
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
94 ´Ø¿ô¤Ï¡¢¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤Îµ½Ò¥Õ¥¡¥¤¥ë \fIfilename\fP ¤ò¥ª¡¼¥×¥ó¤·¤Æ¡¢
95 ¤½¤Î¥Õ¥¡¥¤¥ë¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£¤³¤Î¥Õ¥¡¥¤¥ë¥Ý¥¤¥ó¥¿¤Ï
97 ¤Ë¤è¤Ã¤ÆÍѤ¤¤é¤ì¤ë¡£°ú¤¿ô \fItype\fP ¤ÏÍ׵᤹¤ë¥¢¥¯¥»¥¹·Á¼°¤Ç¡¢
99 ¤Î \fImode\fP °ú¤¿ô¤ÈƱ¤¸Ãͤò¼è¤ë¤³¤È¤¬¤Ç¤¤ë¡£
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.
107 .\"O points to a static area of memory which is overwritten by subsequent
109 .\"O .BR getmntent ().
111 ´Ø¿ô¤Ï¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤Îµ½Ò¥Õ¥¡¥¤¥ë \fIfp\fP ¤«¤é¿·¤·¤¤¹Ô¤òÆÉ
112 ¤ß¹þ¤ß¡¢¹Ô¤ò¥Õ¥£¡¼¥ë¥É¤Ëʬ³ä¤·¤¿ÆâÍƤò¼ý¤á¤¿¹½Â¤ÂΤؤΥݥ¤¥ó¥¿¤òÊÖ¤¹¡£
113 ¥Ý¥¤¥ó¥¿¤Ï¥á¥â¥ê¤ÎÀÅŪ¤ÊÎΰè¤ò»Ø¤·¤Æ¤ª¤ê¡¢¤³¤ÎÎΰè¤Ï
115 ¤ò¼¡¤Ë¸Æ¤Ó½Ð¤·¤¿¤È¤¤Ë¾å½ñ¤¤µ¤ì¤Æ¤·¤Þ¤¦¡£
118 .\"O .BR addmntent ()
119 .\"O function adds the
121 .\"O structure \fImnt\fP to
122 .\"O the end of the open file \fIfp\fP.
126 ¹½Â¤ÂÎ \fImnt\fP ¤ÎÆâÍƤò¡¢¥ª¡¼¥×¥ó¤µ¤ì¤Æ¤¤¤ë¥Õ¥¡¥¤¥ë
127 \fIfp\fP ¤ÎºÇ¸å¤ËÄɲ乤롣
130 .\"O .BR endmntent ()
131 .\"O function closes the file system description file
134 ´Ø¿ô¤Ï¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤Îµ½Ò¥Õ¥¡¥¤¥ë \fIfp\fP ¤òÊĤ¸¤ë¡£
137 .\"O .BR hasmntopt ()
138 .\"O function scans the \fImnt_opts\fP field (see below)
141 .\"O structure \fImnt\fP for a substring that matches \fIopt\fP.
142 .\"O See \fI<mntent.h>\fP and
144 .\"O for valid mount options.
148 ¹½Â¤ÂÎ \fImnt\fP ¤Î \fImnt_opts\fP ¥Õ¥£¡¼¥ë¥É (²¼µ
149 »²¾È) ¤ò¥¹¥¥ã¥ó¤·¡¢ \fIopt\fP ¤Ë°ìÃפ¹¤ëÉôʬʸ»úÎ󤬤¢¤ë¤«¤òÄ´¤Ù¤ë¡£
150 ͸ú¤Ê¥Þ¥¦¥ó¥È¥ª¥×¥·¥ç¥ó¤Ë¤Ä¤¤¤Æ¤Ï \fI<mntent.h>\fP ¤È
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
158 .\"O and stores the strings pointed to by the entries in that struct
159 .\"O in the provided array
170 ¤Ë \fIstruct mount\fP ¤ò³ÊǼ¤·¡¢¤½¤Î¹½Â¤ÂΤγƥ¨¥ó¥È¥ê¤¬»Ø¤·¼¨¤¹Ê¸»úÎó¤ò
171 ¥æ¡¼¥¶¤¬ÍÑ°Õ¤·¤¿Â礤µ
178 .\"O The \fImntent\fP structure is defined in \fI<mntent.h>\fP as follows:
179 \fImntent\fP ¹½Â¤ÂÎ¤Ï \fI<mntent.h>\fP ¤Ç°Ê²¼¤Î¤è¤¦¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡£
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 */
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
201 .\"O .BR addmntent ()
203 .\"O .BR getmntent ()
205 .\"O from string representation to escaped representation and back.
206 mtab ¤ä fstab ¥Õ¥¡¥¤¥ë¤Ç¤Ï¡¢³Æ¥Õ¥£¡¼¥ë¥É¤Ï¶õÇò¤Ç¶èÀÚ¤é¤ì¤Æ¤¤¤ë¤Î¤Ç¡¢
207 ¥¹¥Ú¡¼¥¹¡¢¥¿¥Ö¡¢²þ¹Ô¡¢¥Ð¥Ã¥¯¥¹¥é¥Ã¥·¥å¤Î 4ʸ»ú¤ò¤³¤ì¤é¤Î¥Õ¥¡¥¤¥ë¤Ç
210 ¹½Â¤ÂΤΠ4¤Ä¤Îʸ»úÎó¥á¥ó¥Ð¡¼¤Î¤¤¤º¤ì¤«¤ËÂбþ¤¹¤ë¥Õ¥£¡¼¥ë¥ÉÆâ¤Ç
211 »È¤¤¤¿¤¤¾ì¹ç¤Ë¤Ï¡¢8¿Ê¤Î¥¨¥¹¥±¡¼¥×ɽµ¤ò»È¤Ã¤Æɽ¸½¤¹¤ë:
212 ¥¹¥Ú¡¼¥¹ (\e040), ¥¿¥Ö (\e011), ²þ¹Ô (\e012), ¥Ð¥Ã¥¯¥¹¥é¥Ã¥·¥å (\e134)¡£
217 ¥¨¥¹¥±¡¼¥×ɽ¸½¤Ø¤ÎÊÑ´¹¡¢¤ª¤è¤Ó¤½¤ÎµÕ¤ò¹Ô¤¦¡£
218 .\"O .SH "RETURN VALUE"
221 .\"O .BR getmntent ()
223 .\"O .BR getmntent_r ()
224 .\"O functions return
225 .\"O a pointer to the
227 .\"O structure or NULL on failure.
233 ¹½Â¤ÂΤؤΥݥ¤¥ó¥¿¤òÊÖ¤¹¡£
234 ¼ºÇÔ¤·¤¿¾ì¹ç¤Ï NULL ¤òÊÖ¤¹¡£
237 .\"O .BR addmntent ()
238 .\"O function returns 0 on success and 1 on failure.
239 .\Baddmntent\fP() ´Ø¿ô¤ÏÀ®¸ù¤·¤¿¤é 0 ¤òÊÖ¤·¡¢¼ºÇÔ¤·¤¿¤é 1 ¤òÊÖ¤¹¡£
242 .\"O .BR endmntent ()
243 .\"O function always returns 1.
245 ´Ø¿ô¤Ï¤Ä¤Í¤Ë 1 ¤òÊÖ¤¹¡£
248 .\"O .BR hasmntopt ()
249 .\"O function returns the address of the substring if
250 .\"O a match is found and NULL otherwise.
252 ´Ø¿ô¤Ï¡¢¥Þ¥Ã¥Á¤·¤¿¾ì¹ç¤ÏÉôʬʸ»úÎó¤Ø¤Î¥¢¥É¥ì¥¹¤òÊÖ¤·¡¢
253 ¥Þ¥Ã¥Á¤·¤Ê¤±¤ì¤Ð NULL ¤òÊÖ¤¹¡£
257 .\"O /etc/fstab file system description file
258 .\"O /etc/mtab mounted file system description file
259 /etc/fstab ¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥àµ½Ò¥Õ¥¡¥¤¥ë
260 /etc/mtab ¥Þ¥¦¥ó¥È¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤Îµ½Ò¥Õ¥¡¥¤¥ë
262 .\"O .SH "CONFORMING TO"
264 .\"O The nonreentrant functions are from SunOS 4.1.3.
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 ͳÍè¤Î¤â¤Î¤Ç¤¢¤ë¡£
271 ´Ø¿ô¤Ï HPUX 10 ¤ÇƳÆþ¤µ¤ì¤¿¤¬¡¢¤³¤Î¥Ð¡¼¥¸¥ç¥ó¤Ç¤Ï int ¤òÊÖ¤¹¡£
272 ¾åµ¤Ë¼¨¤·¤¿¥×¥í¥È¥¿¥¤¥×¤Ï glibc Æȼ«¤Î¤â¤Î¤Ç¤¢¤ë¡£
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.
285 ¸Æ¤Ó½Ð¤·¼ê½ç¤¬°Û¤Ê¤ê¡¢ÊÖ¤µ¤ì¤ë¹½Â¤ÂΤâ°Û¤Ê¤ë¡£
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 ¤Ë¤Ï
298 ¤Î¥é¥Ã¥Ñ¡¼´Ø¿ô¤Ç¤¢¤ë¡£