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)):
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 の内容を、オープンされているファイル
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 を格納し、その構造体の各エントリが指し示す文字列を
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.
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.
248 .\"O .BR hasmntopt ()
249 .\"O function returns the address of the substring if
250 .\"O a match is found and NULL otherwise.
252 関数は、マッチした場合は部分文字列へのアドレスを返し、
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 には