OSDN Git Service

22824b36831f843258da23e3b51cf46e0f24221f
[linuxjm/LDP_man-pages.git] / draft / man2 / statfs.2
1 .\" Copyright (C) 2003 Andries Brouwer (aeb@cwi.nl)
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 .\" Modified 2003-08-17 by Walter Harms
24 .\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
25 .\"
26 .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
27 .\"         all rights reserved.
28 .\" Translated Fri Dec 12 00:25:54 JST 1997
29 .\"         by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
30 .\" Updated & Modified Sat Jun  2 20:25:46 JST 2001
31 .\"         by Yuichi SATO <ysato@h4.dion.ne.jp>
32 .\" Updated & Modified Sat Jan 18 16:48:08 JST 2003
33 .\"         by Yuichi SATO <ysato444@yahoo.co.jp>
34 .\" Updated & Modified Sun Sep  7 00:52:44 JST 2003 by Yuichi SATO
35 .\" Updated & Modified Sun Jan  9 22:35:28 JST 2005 by Yuichi SATO
36 .\" Updated 2006-07-21, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.36
37 .\"
38 .\"WORD:        file system             ファイル・システム
39 .\"WORD:        mount                   マウント
40 .\"WORD:        pointer                 ポインター
41 .\"WORD:        descriptor              ディスクリプター
42 .\"WORD:        open                    オープン
43 .\"WORD:        symbolic link           シンボリック・リンク
44 .\"WORD:        open                    オープン
45 .\"
46 .TH STATFS 2 2010-09-04 "Linux" "Linux Programmer's Manual"
47 .\"O .SH NAME
48 .SH 名前
49 .\"O statfs, fstatfs \- get file system statistics
50 statfs, fstatfs \- ファイル・システムの統計を得る
51 .\"O .SH SYNOPSIS
52 .SH 書式
53 .\"O .BR "#include <sys/vfs.h>    " "/* or <sys/statfs.h> */"
54 .BR "#include <sys/vfs.h>    " "/* または <sys/statfs.h> */"
55 .sp
56 .BI "int statfs(const char *" path ", struct statfs *" buf );
57 .br
58 .BI "int fstatfs(int " fd ", struct statfs *" buf );
59 .\"O .SH DESCRIPTION
60 .SH 書式
61 .\"O The function
62 .\"O .BR statfs ()
63 .\"O returns information about a mounted file system.
64 関数
65 .BR statfs ()
66 はマウントされたファイル・システムについての情報を返す。
67 .\"O .I path
68 .\"O is the pathname of any file within the mounted file system.
69 .I path
70 はマウントされたファイル・システムにあるファイルのパス名である。
71 .\"O .I buf
72 .\"O is a pointer to a
73 .\"O .I statfs
74 .\"O structure defined approximately as follows:
75 .I buf
76
77 .I statfs
78 構造体へのポインターで、およそ以下のように定義される:
79
80 .in +4n
81 .nf
82 .\"O #if __WORDSIZE == 32               /* System word size */
83 #if __WORDSIZE == 32            /* システムのワードサイズ */
84 # define __SWORD_TYPE           int
85 #else /* __WORDSIZE == 64 */
86 # define __SWORD_TYPE           long int
87 #endif
88
89 struct statfs {
90 .\"O     __SWORD_TYPE f_type;    /* type of file system (see below) */
91 .\"O     __SWORD_TYPE f_bsize;   /* optimal transfer block size */
92 .\"O     fsblkcnt_t   f_blocks;  /* total data blocks in file system */
93 .\"O     fsblkcnt_t   f_bfree;   /* free blocks in fs */
94 .\"O     fsblkcnt_t   f_bavail;  /* free blocks available to
95 .\"O                                unprivileged user */
96 .\"O     fsfilcnt_t   f_files;   /* total file nodes in file system */
97 .\"O     fsfilcnt_t   f_ffree;   /* free file nodes in fs */
98 .\"O     fsid_t       f_fsid;    /* file system id */
99 .\"O     __SWORD_TYPE f_namelen; /* maximum length of filenames */
100 .\"O     __SWORD_TYPE f_frsize;  /* fragment size (since Linux 2.6) */
101 .\"O     __SWORD_TYPE f_spare[5];
102     __SWORD_TYPE f_type;    /* ファイルシステムの種別 (下記参照) */
103     __SWORD_TYPE f_bsize;   /* 最適な転送ブロックサイズ */
104     fsblkcnt_t   f_blocks;  /* ファイルシステムの総データブロック数 */
105     fsblkcnt_t   f_bfree;   /* ファイルシステムの空きブロック数 */
106     fsblkcnt_t   f_bavail;  /* 非特権ユーザが利用可能な空きブロック数 */
107     fsfilcnt_t   f_files;   /* ファイルシステムの総ファイルノード数 */
108     fsfilcnt_t   f_ffree;   /* ファイルシステムの空きファイルノード数 */
109     fsid_t       f_fsid;    /* ファイルシステムの ID */
110     __SWORD_TYPE f_namelen; /* ファイル名の最大長 */
111     __SWORD_TYPE f_frsize;  /* フラグメントサイズ (Linux 2.6 以降) */
112     __SWORD_TYPE f_spare[5];
113 };
114
115 .\"O File system types:
116 ファイル・システムの型:
117
118    ADFS_SUPER_MAGIC      0xadf5
119    AFFS_SUPER_MAGIC      0xADFF
120    BEFS_SUPER_MAGIC      0x42465331
121    BFS_MAGIC             0x1BADFACE
122    CIFS_MAGIC_NUMBER     0xFF534D42
123    CODA_SUPER_MAGIC      0x73757245
124    COH_SUPER_MAGIC       0x012FF7B7
125    CRAMFS_MAGIC          0x28cd3d45
126    DEVFS_SUPER_MAGIC     0x1373
127    EFS_SUPER_MAGIC       0x00414A53
128    EXT_SUPER_MAGIC       0x137D
129    EXT2_OLD_SUPER_MAGIC  0xEF51
130    EXT2_SUPER_MAGIC      0xEF53
131    EXT3_SUPER_MAGIC      0xEF53
132    EXT4_SUPER_MAGIC      0xEF53
133    HFS_SUPER_MAGIC       0x4244
134    HPFS_SUPER_MAGIC      0xF995E849
135    HUGETLBFS_MAGIC       0x958458f6
136    ISOFS_SUPER_MAGIC     0x9660
137    JFFS2_SUPER_MAGIC     0x72b6
138    JFS_SUPER_MAGIC       0x3153464a
139 .\"O    MINIX_SUPER_MAGIC     0x137F /* orig. minix */
140    MINIX_SUPER_MAGIC     0x137F /* オリジナルの minix */
141 .\"O    MINIX_SUPER_MAGIC2    0x138F /* 30 char minix */
142    MINIX_SUPER_MAGIC2    0x138F /* 30 文字ファイル名の minix */
143    MINIX2_SUPER_MAGIC    0x2468 /* minix V2 */
144 .\"O    MINIX2_SUPER_MAGIC2   0x2478 /* minix V2, 30 char names */
145    MINIX2_SUPER_MAGIC2   0x2478 /* minix V2, 30 文字ファイル名 */
146    MSDOS_SUPER_MAGIC     0x4d44
147    NCP_SUPER_MAGIC       0x564c
148    NFS_SUPER_MAGIC       0x6969
149    NTFS_SB_MAGIC         0x5346544e
150    OPENPROM_SUPER_MAGIC  0x9fa1
151    PROC_SUPER_MAGIC      0x9fa0
152    QNX4_SUPER_MAGIC      0x002f
153    REISERFS_SUPER_MAGIC  0x52654973
154    ROMFS_MAGIC           0x7275
155    SMB_SUPER_MAGIC       0x517B
156    SYSV2_SUPER_MAGIC     0x012FF7B6
157    SYSV4_SUPER_MAGIC     0x012FF7B5
158    TMPFS_MAGIC           0x01021994
159    UDF_SUPER_MAGIC       0x15013346
160    UFS_MAGIC             0x00011954
161    USBDEVICE_SUPER_MAGIC 0x9fa2
162    VXFS_SUPER_MAGIC      0xa501FCF5
163    XENIX_SUPER_MAGIC     0x012FF7B4
164    XFS_SUPER_MAGIC       0x58465342
165    _XIAFS_SUPER_MAGIC    0x012FD16D
166 .fi
167 .in
168 .PP
169 .\"O Nobody knows what
170 .\"O .I f_fsid
171 .\"O is supposed to contain (but see below).
172 .I f_fsid
173 にどんな値が入るべきなのかは誰も知らない (但し、下記を参照)。
174 .PP
175 .\"O Fields that are undefined for a particular file system are set to 0.
176 .\"O .BR fstatfs ()
177 .\"O returns the same information about an open file referenced by descriptor
178 .\"O .IR fd .
179 それぞれのファイル・システムにおいて未定義のフィールドには 0 が
180 設定される。
181 .BR fstatfs ()
182 はディスクリプター
183 .I fd
184 によって参照されるオープンされたファイルについて、同じ情報を返す。
185 .\"O .SH "RETURN VALUE"
186 .SH 返り値
187 .\"O On success, zero is returned.
188 .\"O On error, \-1 is returned, and
189 .\"O .I errno
190 .\"O is set appropriately.
191 成功すれば 0 が返される。エラーの場合は \-1 が返され、
192 .I errno
193 が適切に設定される。
194 .\"O .SH ERRORS
195 .SH エラー
196 .TP
197 .B EACCES
198 .\"O .RB ( statfs ())
199 .\"O Search permission is denied for a component of the path prefix of
200 .\"O .IR path .
201 .RB ( statfs ()
202 の場合)
203 .I path
204 のディレクトリ部分に検索許可が与えられていない
205 .\"O (See also
206 .\"O .BR path_resolution (7).)
207 .RB ( path_resolution (7)
208 も参照すること)。
209 .TP
210 .B EBADF
211 .\"O .RB ( fstatfs ())
212 .\"O .I fd
213 .\"O is not a valid open file descriptor.
214 .RB ( fstatfs ()
215 の場合)
216 .I fd
217 は有効なオープンされたファイル・ディスクリプターではない。
218 .TP
219 .B EFAULT
220 .\"O .I buf
221 .\"O or
222 .\"O .I path
223 .\"O points to an invalid address.
224 .I buf
225 または
226 .I path
227 が不正なアドレスを指している。
228 .TP
229 .B EINTR
230 .\"O This call was interrupted by a signal.
231 この呼び出しがシグナルで中断された。
232 .TP
233 .B EIO
234 .\"O An I/O error occurred while reading from the file system.
235 ファイル・システムの読み込みの間に I/O エラーが発生した。
236 .TP
237 .B ELOOP
238 .\"O .RB ( statfs ())
239 .\"O Too many symbolic links were encountered in translating
240 .\"O .IR path .
241 .RB ( statfs ()
242 の場合)
243 .I path
244 を解決するのに辿るべきシンボリック・リンクが多すぎる。
245 .TP
246 .B ENAMETOOLONG
247 .\"O .RB ( statfs ())
248 .\"O .I path
249 .\"O is too long.
250 .RB ( statfs ()
251 の場合)
252 .I path
253 が長過ぎる。
254 .TP
255 .B ENOENT
256 .\"O .RB ( statfs ())
257 .\"O The file referred to by
258 .\"O .I path
259 .\"O does not exist.
260 .RB ( statfs ()
261 の場合)
262 .I path
263 によって参照されるファイルが存在しない。
264 .TP
265 .B ENOMEM
266 .\"O Insufficient kernel memory was available.
267 カーネルに十分なメモリがない。
268 .TP
269 .B ENOSYS
270 .\"O The file system does not support this call.
271 ファイル・システムがこの呼び出しをサポートしていない。
272 .TP
273 .B ENOTDIR
274 .\"O .RB ( statfs ())
275 .\"O A component of the path prefix of
276 .\"O .I path
277 .\"O is not a directory.
278 .RB ( statfs ()
279 の場合)
280 .I path
281 のディレクトリ部分がディレクトリでない。
282 .TP
283 .B EOVERFLOW
284 .\"O Some values were too large to be represented in the returned struct.
285 値が大き過ぎるため、返り値の構造体で表現できない。
286 .\"O .SH "CONFORMING TO"
287 .SH 準拠
288 .\"O Linux-specific.
289 .\"O The Linux
290 .\"O .BR statfs ()
291 .\"O was inspired by the 4.4BSD one
292 .\"O (but they do not use the same structure).
293 Linux 固有である。
294 Linux の
295 .BR statfs ()
296 は 4.4BSD のものに影響を受けている。
297 (しかし同じ構造体を使用しているわけではない)
298 .\"O .SH NOTES
299 .SH 注意
300 .\"O The kernel has system calls
301 .\"O .BR statfs (),
302 .\"O .BR fstatfs (),
303 .\"O .BR statfs64 (),
304 .\"O and
305 .\"O .BR fstatfs64 ()
306 .\"O to support this library call.
307 このライブラリコールをサポートするため、
308 カーネルにはシステムコール
309 .BR statfs (),
310 .BR fstatfs (),
311 .BR statfs64 (),
312 .BR fstatfs64 ()
313 がある。
314
315 .\"O Some systems only have \fI<sys/vfs.h>\fP, other systems also have
316 .\"O \fI<sys/statfs.h>\fP, where the former includes the latter.
317 .\"O So it seems
318 .\"O including the former is the best choice.
319 \fI<sys/vfs.h>\fP しか持たないシステムもあり、
320 \fI<sys/statfs.h>\fP も持っているシステムもある。
321 前者は後者をインクルードするので、
322 前者をインクルードするのが良いと考えられる。
323
324 .\"O LSB has deprecated the library calls
325 .\"O .BR statfs ()
326 .\"O and
327 .\"O .BR fstatfs ()
328 .\"O and tells us to use
329 .\"O .BR statvfs (2)
330 .\"O and
331 .\"O .BR fstatvfs (2)
332 .\"O instead.
333 LSB ではライブラリコール
334 .BR statfs (),
335 .BR fstatfs ()
336 を非推奨として、代わりに
337 .BR statvfs (2),
338 .BR fstatvfs (2)
339 を使うように指示している。
340 .\"O .SS The f_fsid field
341 .SS f_fsid フィールド
342 .\"O Solaris, Irix and POSIX have a system call
343 .\"O .BR statvfs (2)
344 .\"O that returns a
345 .\"O .I "struct statvfs"
346 .\"O (defined in
347 .\"O .IR <sys/statvfs.h> )
348 .\"O containing an
349 .\"O .I "unsigned long"
350 .\"O .IR f_fsid .
351 Solaris, Irix, POSIX にはシステムコール
352 .BR statvfs (2)
353 があり、
354 .I "struct statvfs"
355 を返す
356 .RI ( <sys/statvfs.h>
357 で定義されている)。
358 この構造体には、
359 .I "unsigned long"
360 .I f_fsid
361 が含まれている。
362 .\"O Linux, SunOS, HP-UX, 4.4BSD have a system call
363 .\"O .BR statfs ()
364 .\"O that returns a
365 .\"O .I "struct statfs"
366 .\"O (defined in
367 .\"O .IR <sys/vfs.h> )
368 .\"O containing a
369 .\"O .I fsid_t
370 .\"O .IR f_fsid ,
371 .\"O where
372 .\"O .I fsid_t
373 .\"O is defined as
374 .\"O .IR "struct { int val[2]; }" .
375 Linux, SunOS, HP-UX, 4.4BSD にはシステムコール
376 .BR statfs ()
377 があり、
378 .I "struct statfs"
379 を返す
380 .RI ( <sys/vfs.h>
381 で定義されている)。
382 この構造体には
383 .I fsid_t
384 .IR f_fsid ,
385 が含まれており、
386 .I fsid_t
387
388 .I "struct { int val[2]; }"
389 と定義されている。
390 .\"O The same holds for FreeBSD, except that it uses the include file
391 .\"O .IR <sys/mount.h> .
392 FreeBSD でも同じであるが、インクルードファイル
393 .I <sys/mount.h>
394 を使う。
395
396 .\"O The general idea is that
397 .\"O .I f_fsid
398 .\"O contains some random stuff such that the pair
399 .\"O .RI ( f_fsid , ino )
400 .\"O uniquely determines a file.
401 .I f_fsid
402 はあるランダムな値を持ち、
403 .RI ( f_fsid , ino )
404 という 1 組の値でファイルを一意に決定できるようにする、
405 というのが基本的な考え方である。
406 .\"O Some operating systems use (a variation on) the device number, or the device number
407 .\"O combined with the file-system type.
408 いくつかの OS では、デバイス番号 (の変種) を使ったり、
409 デバイス番号とファイル・システムタイプを組み合わせて使ったりしている。
410 .\"O Several OSes restrict giving out the
411 .\"O .I f_fsid
412 .\"O field to the superuser only (and zero it for unprivileged users),
413 .\"O because this field is used in the filehandle of the file system
414 .\"O when NFS-exported, and giving it out is a security concern.
415 OS の中には
416 .I f_fsid
417 フィールドの取得をスーパーユーザに限定しているものもある
418 (非特権ユーザが取得すると 0 となる)。
419 NFS でエクスポートされる場合、
420 このフィールドがファイル・システムのファイルハンドルで使われており、
421 この値を提供するとセキュリティ上の問題がある。
422 .LP
423 .\"O Under some operating systems the
424 .\"O .I fsid
425 .\"O can be used as second argument to the
426 .\"O .BR sysfs (2)
427 .\"O system call.
428 いくつかの OS では、
429 .I fsid
430
431 .BR sysfs (2)
432 システムコールの第 2 引き数として使用できる。
433 .\"O .SH "SEE ALSO"
434 .SH 関連項目
435 .BR stat (2),
436 .BR statvfs (2),
437 .BR path_resolution (7)