OSDN Git Service

ae20388fd0c844ff2ef2b5403a055671f709d1f8
[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)