.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) .\" .\" %%%LICENSE_START(VERBATIM) .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" %%%LICENSE_END .\" .\" References consulted: .\" Linux libc source code .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) .\" 386BSD man pages .\" Modified Sat Jul 24 21:46:57 1993 by Rik Faith (faith@cs.unc.edu) .\" Modified 961109, 031115, aeb .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 1998 NAKANO Takeo all rights reserved. .\" Translated 1998-03-01, NAKANO Takeo .\" Updated 2000-09-03, Kentaro Shirakata .\" Updated 2005-03-18, Akihiro MOTOKI .\" .TH GETMNTENT 3 2019\-03\-06 "" "Linux Programmer's Manual" .SH 名前 getmntent, setmntent, addmntent, endmntent, hasmntopt, getmntent_r \- ファイルシステム記述ファイルのエントリーを取得する .SH 書式 .nf \fB#include \fP \fB#include \fP .PP \fBFILE *setmntent(const char *\fP\fIfilename\fP\fB, const char *\fP\fItype\fP\fB);\fP .PP \fBstruct mntent *getmntent(FILE *\fP\fIstream\fP\fB);\fP .PP \fBint addmntent(FILE *\fP\fIstream\fP\fB, const struct mntent *\fP\fImnt\fP\fB);\fP .PP \fBint endmntent(FILE *\fP\fIstreamp\fP\fB);\fP .PP \fBchar *hasmntopt(const struct mntent *\fP\fImnt\fP\fB, const char *\fP\fIopt\fP\fB);\fP /* GNU による拡張 */ \fB#include \fP .PP \fBstruct mntent *getmntent_r(FILE *\fP\fIstreamp\fP\fB, struct mntent *\fP\fImntbuf\fP\fB,\fP \fB char *\fP\fIbuf\fP\fB, int \fP\fIbuflen\fP\fB);\fP .fi .PP .RS -4 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): .RE .PP \fBgetmntent_r\fP(): Since glibc 2.19: _DEFAULT_SOURCE Glibc 2.19 and earlier: _BSD_SOURCE || _SVID_SOURCE .SH 説明 これらのルーチンは、ファイルシステムを記述したファイル \fI/etc/fstab\fP と、マウントされているファイルシステムを記述したファイル \fI/etc/mtab\fP にアクセスするために用いられる。 .PP The \fBsetmntent\fP() function opens the filesystem description file \fIfilename\fP and returns a file pointer which can be used by \fBgetmntent\fP(). The argument \fItype\fP is the type of access required and can take the same values as the \fImode\fP argument of \fBfopen\fP(3). The returned stream should be closed using \fBendmntent\fP() rather than \fBfclose\fP(3). .PP \fBgetmntent\fP() 関数は \fIstream\fP からファイルシステムの記述ファイルの次の行を読み込み、 読み込んだ行をフィールドに分割した内容を収めた構造体へのポインターを返す。 ポインターはメモリーの静的な領域を指しており、この領域は \fBgetmntent\fP() を次に呼び出したときに上書きされてしまう。 .PP \fBaddmntent\fP() 関数は \fImntent\fP 構造体 \fImnt\fP の内容を、オープンされている \fIstream\fP の最後に追加する。 .PP \fBendmntent\fP() 関数はファイルシステムの記述ファイルに関連付けられている \fIstream\fP を閉じる。 .PP \fBhasmntopt\fP() 関数は \fImntent\fP 構造体 \fImnt\fP の \fImnt_opts\fP フィールド (下記 参照) をスキャンし、 \fIopt\fP に一致する部分文字列があるかを調べる。 有効なマウントオプションについては \fI\fP と \fBmount\fP(8) を参照のこと。 .PP リエントラントな関数 \fBgetmntent_r\fP() は \fBgetmntent\fP() と同じだが、 ユーザーが用意した \fI*mntbuf\fP に \fIstruct mount\fP を格納し、その構造体の各エントリーが指し示す文字列を ユーザーが用意した大きさ \fIbuflen\fP の配列 \fIbuf\fP に書き込む。 .PP \fImntent\fP 構造体は \fI\fP で以下のように定義されている。 .PP .in +4n .EX struct mntent { char *mnt_fsname; /* name of mounted file system */ char *mnt_dir; /* file system path prefix */ char *mnt_type; /* mount type (see mntent.h) */ char *mnt_opts; /* mount options (see mntent.h) */ int mnt_freq; /* dump frequency in days */ int mnt_passno; /* pass number on parallel fsck */ }; .EE .in .PP Since fields in the mtab and fstab files are separated by whitespace, octal escapes are used to represent the characters space (\e040), tab (\e011), newline (\e012), and backslash (\e\e) in those files when they occur in one of the four strings in a \fImntent\fP structure. The routines \fBaddmntent\fP() and \fBgetmntent\fP() will convert from string representation to escaped representation and back. When converting from escaped representation, the sequence \e134 is also converted to a backslash. .SH 返り値 \fBgetmntent\fP() と \fBgetmntent_r\fP() は \fImntent\fP 構造体へのポインターを返す。 失敗した場合は NULL を返す。 .PP \fBaddmntent\fP() 関数は成功したら 0 を返し、失敗したら 1 を返す。 .PP \fBendmntent\fP() 関数はつねに 1 を返す。 .PP \fBhasmntopt\fP() 関数は、マッチした場合は部分文字列へのアドレスを返し、 マッチしなければ NULL を返す。 .SH ファイル .TP \fI/etc/fstab\fP filesystem description file .TP \fI/etc/mtab\fP mounted filesystem description file .SH 属性 この節で使用されている用語の説明については、 \fBattributes\fP(7) を参照。 .ad l .TS allbox; lbw13 lb lbw31 l l l. インターフェース 属性 値 T{ \fBsetmntent\fP(), \fBendmntent\fP(), \fBhasmntopt\fP() T} Thread safety MT\-Safe T{ \fBgetmntent\fP() T} Thread safety MT\-Unsafe race:mntentbuf locale T{ \fBaddmntent\fP() T} Thread safety MT\-Safe race:stream locale T{ \fBgetmntent_r\fP() T} Thread safety MT\-Safe locale .TE .ad .SH 準拠 リエントラントでない関数は SunOS 4.1.3 由来のものである。 \fBgetmntent_r\fP() 関数は HPUX 10 で導入されたが、このバージョンでは \fIint\fP を返す。 上記に示したプロトタイプは glibc 独自のものである。 .SH 注意 System V にも \fBgetmntent\fP() 関数はあるが、 呼び出し手順が異なり、返される構造体も異なる。 System V では \fI/etc/mnttab\fP が用いられる。 4.4BSD と Digital UNIX には \fBgetmntinfo\fP() があるが、 システムコール \fBgetfsstat\fP() のラッパー関数である。 .SH 関連項目 \fBfopen\fP(3), \fBfstab\fP(5), \fBmount\fP(8) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は \%https://www.kernel.org/doc/man\-pages/ に書かれている。