OSDN Git Service

(split) LDP: Release pages for LDP v3.39.
[linuxjm/LDP_man-pages.git] / release / 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 .\"*******************************************************************
31 .\"
32 .\" This file was generated with po4a. Translate the source file.
33 .\"
34 .\"*******************************************************************
35 .TH GETMNTENT 3 2009\-09\-15 "" "Linux Programmer's Manual"
36 .SH 名前
37 getmntent, setmntent, addmntent, endmntent, hasmntopt, getmntent_r \-
38 ファイルシステム記述ファイルのエントリを取得する
39 .SH 書式
40 .nf
41 \fB#include <stdio.h>\fP
42 \fB#include <mntent.h>\fP
43 .sp
44 \fBFILE *setmntent(const char *\fP\fIfilename\fP\fB, const char *\fP\fItype\fP\fB);\fP
45 .sp
46 \fBstruct mntent *getmntent(FILE *\fP\fIfp\fP\fB);\fP
47 .sp
48 \fBint addmntent(FILE *\fP\fIfp\fP\fB, const struct mntent *\fP\fImnt\fP\fB);\fP
49 .sp
50 \fBint endmntent(FILE *\fP\fIfp\fP\fB);\fP
51 .sp
52 \fBchar *hasmntopt(const struct mntent *\fP\fImnt\fP\fB, const char *\fP\fIopt\fP\fB);\fP
53 .sp
54 /* GNU による拡張 */
55 \fB#include <mntent.h>\fP
56 .sp
57 \fBstruct mntent *getmntent_r(FILE *\fP\fIfp\fP\fB, struct mntent *\fP\fImntbuf\fP\fB,\fP
58 \fB                           char *\fP\fIbuf\fP\fB, int \fP\fIbuflen\fP\fB);\fP
59 .fi
60 .sp
61 .in -4n
62 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
63 .in
64 .sp
65 \fBgetmntent_r\fP(): _BSD_SOURCE || _SVID_SOURCE
66 .SH 説明
67 これらのルーチンは、ファイルシステムを記述したファイル \fI/etc/fstab\fP と、マウントされているファイルシステムを記述したファイル
68 \fI/etc/mtab\fP にアクセスするために用いられる。
69 .PP
70 \fBsetmntent\fP()  関数は、ファイルシステムの記述ファイル \fIfilename\fP をオープンして、
71 そのファイルポインタを返す。このファイルポインタは \fBgetmntent\fP()  によって用いられる。引き数 \fItype\fP
72 は要求するアクセス形式で、 \fBfopen\fP(3)  の \fImode\fP 引き数と同じ値を取ることができる。
73 .PP
74 \fBgetmntent\fP()  関数はファイルシステムの記述ファイル \fIfp\fP から新しい行を読
75 み込み、行をフィールドに分割した内容を収めた構造体へのポインタを返す。 ポインタはメモリの静的な領域を指しており、この領域は
76 \fBgetmntent\fP()  を次に呼び出したときに上書きされてしまう。
77 .PP
78 \fBaddmntent\fP()  関数は \fImntent\fP 構造体 \fImnt\fP の内容を、オープンされているファイル \fIfp\fP の最後に追加する。
79 .PP
80 \fBendmntent\fP()  関数はファイルシステムの記述ファイル \fIfp\fP を閉じる。
81 .PP
82 \fBhasmntopt\fP()  関数は \fImntent\fP 構造体 \fImnt\fP の \fImnt_opts\fP フィールド (下記 参照) をスキャンし、
83 \fIopt\fP に一致する部分文字列があるかを調べる。 有効なマウントオプションについては \fI<mntent.h>\fP と
84 \fBmount\fP(8)  を参照のこと。
85 .PP
86 リエントラントな関数 \fBgetmntent_r\fP()  は \fBgetmntent\fP()  と同じだが、 ユーザが用意した \fI*mntbuf\fP に
87 \fIstruct mount\fP を格納し、その構造体の各エントリが指し示す文字列を ユーザが用意した大きさ \fIbuflen\fP の配列 \fIbuf\fP
88 に書き込む。
89 .PP
90 \fImntent\fP 構造体は \fI<mntent.h>\fP で以下のように定義されている。
91 .sp
92 .in +4n
93 .nf
94 struct mntent {
95     char *mnt_fsname;   /* name of mounted file system */
96     char *mnt_dir;      /* file system path prefix */
97     char *mnt_type;     /* mount type (see mntent.h) */
98     char *mnt_opts;     /* mount options (see mntent.h) */
99     int   mnt_freq;     /* dump frequency in days */
100     int   mnt_passno;   /* pass number on parallel fsck */
101 };
102 .fi
103 .in
104
105 mtab や fstab ファイルでは、各フィールドは空白で区切られているので、 スペース、タブ、改行、バックスラッシュの 4文字をこれらのファイルで
106 使いたい場合で、かつ \fImntent\fP 構造体の 4つの文字列メンバーのいずれかに対応するフィールド内で
107 使いたい場合には、8進のエスケープ表記を使って表現する: スペース (\e040), タブ (\e011), 改行 (\e012), バックスラッシュ
108 (\e134)。 \fBaddmntent\fP()  と \fBgetmntent\fP()  は、文字列表現から エスケープ表現への変換、およびその逆を行う。
109 .SH 返り値
110 \fBgetmntent\fP()  と \fBgetmntent_r\fP()  は \fImntent\fP 構造体へのポインタを返す。 失敗した場合は NULL
111 を返す。
112 .PP
113 \fBaddmntent\fP()  関数は成功したら 0 を返し、失敗したら 1 を返す。
114 .PP
115 \fBendmntent\fP()  関数はつねに 1 を返す。
116 .PP
117 \fBhasmntopt\fP()  関数は、マッチした場合は部分文字列へのアドレスを返し、 マッチしなければ NULL を返す。
118 .SH ファイル
119 .nf
120 /etc/fstab          ファイルシステム記述ファイル
121 /etc/mtab           マウントされたファイルシステムの記述ファイル
122 .fi
123 .SH 準拠
124 リエントラントでない関数は SunOS 4.1.3 由来のものである。 \fBgetmntent_r\fP()  関数は HPUX 10
125 で導入されたが、このバージョンでは int を返す。 上記に示したプロトタイプは glibc 独自のものである。
126 .SH 注意
127 System V にも \fBgetmntent\fP()  関数はあるが、 呼び出し手順が異なり、返される構造体も異なる。 System V では
128 \fI/etc/mnttab\fP が用いられる。 4.4BSD と Digital UNIX には \fBgetmntinfo\fP()  があるが、
129 システムコール \fBgetfsstat\fP()  のラッパー関数である。
130 .SH 関連項目
131 \fBfopen\fP(3), \fBfstab\fP(5), \fBmount\fP(8)