.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) .\" .\" 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. .\" .\" 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 .\" .\" 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 2009-09-15 "" "Linux Programmer's Manual" .\"O .SH NAME .\"O getmntent, setmntent, addmntent, endmntent, hasmntopt, .\"O getmntent_r \- get file system descriptor file entry .SH 名前 getmntent, setmntent, addmntent, endmntent, hasmntopt, getmntent_r \- ファイルシステム記述ファイルのエントリを取得する .\"O .SH SYNOPSIS .SH 書式 .nf .B #include .B #include .sp .BI "FILE *setmntent(const char *" filename ", const char *" type ); .sp .BI "struct mntent *getmntent(FILE *" fp ); .sp .BI "int addmntent(FILE *" fp ", const struct mntent *" mnt ); .sp .BI "int endmntent(FILE *" fp ); .sp .BI "char *hasmntopt(const struct mntent *" mnt ", const char *" opt ); .sp .\"O /* GNU extension */ /* GNU による拡張 */ .B #include .sp .BI "struct mntent *getmntent_r(FILE *" fp ", struct mntent *" mntbuf , .BI " char *" buf ", int " buflen ); .fi .sp .in -4n .\"O Feature Test Macro Requirements for glibc (see .\"O .BR feature_test_macros (7)): glibc 向けの機能検査マクロの要件 .RB ( feature_test_macros (7) 参照): .in .sp .BR getmntent_r (): _BSD_SOURCE || _SVID_SOURCE .\"O .SH DESCRIPTION .SH 説明 .\"O These routines are used to access the file system description file .\"O \fI/etc/fstab\fP and the mounted file system description file .\"O \fI/etc/mtab\fP. これらのルーチンは、ファイルシステムを記述したファイル \fI/etc/fstab\fP と、マウントされているファイルシステムを記述したファイル \fI/etc/mtab\fP にアクセスするために用いられる。 .PP .\"O The .\"O .BR setmntent () .\"O function opens the file system description file .\"O \fIfilename\fP and returns a file pointer which can be used by .\"O .BR getmntent (). .\"O The argument \fItype\fP is the type of access .\"O required and can take the same values as the \fImode\fP argument of .\"O .BR fopen (3). .BR setmntent () 関数は、ファイルシステムの記述ファイル \fIfilename\fP をオープンして、 そのファイルポインタを返す。このファイルポインタは .BR getmntent () によって用いられる。引き数 \fItype\fP は要求するアクセス形式で、 .BR fopen (3) の \fImode\fP 引き数と同じ値を取ることができる。 .PP .\"O The .\"O .BR getmntent () .\"O function reads the next line from the file system .\"O description file \fIfp\fP and returns a pointer to a structure .\"O containing the broken out fields from a line in the file. .\"O The pointer .\"O points to a static area of memory which is overwritten by subsequent .\"O calls to .\"O .BR getmntent (). .BR getmntent () 関数はファイルシステムの記述ファイル \fIfp\fP から新しい行を読 み込み、行をフィールドに分割した内容を収めた構造体へのポインタを返す。 ポインタはメモリの静的な領域を指しており、この領域は .BR getmntent () を次に呼び出したときに上書きされてしまう。 .PP .\"O The .\"O .BR addmntent () .\"O function adds the .\"O .I mntent .\"O structure \fImnt\fP to .\"O the end of the open file \fIfp\fP. .BR addmntent () 関数は .I mntent 構造体 \fImnt\fP の内容を、オープンされているファイル \fIfp\fP の最後に追加する。 .PP .\"O The .\"O .BR endmntent () .\"O function closes the file system description file .\"O \fIfp\fP. .BR endmntent () 関数はファイルシステムの記述ファイル \fIfp\fP を閉じる。 .PP .\"O The .\"O .BR hasmntopt () .\"O function scans the \fImnt_opts\fP field (see below) .\"O of the .\"O .I mntent .\"O structure \fImnt\fP for a substring that matches \fIopt\fP. .\"O See \fI\fP and .\"O .BR mount (8) .\"O for valid mount options. .BR hasmntopt () 関数は .I mntent 構造体 \fImnt\fP の \fImnt_opts\fP フィールド (下記 参照) をスキャンし、 \fIopt\fP に一致する部分文字列があるかを調べる。 有効なマウントオプションについては \fI\fP と .BR mount (8) を参照のこと。 .PP .\"O The reentrant \fBgetmntent_r\fP() function is similar to .\"O .BR getmntent (), .\"O but stores the \fIstruct mount\fP in the provided .\"O .I *mntbuf .\"O and stores the strings pointed to by the entries in that struct .\"O in the provided array .\"O .I buf .\"O of size .\"O .IR buflen . リエントラントな関数 .BR getmntent_r () は .BR getmntent () と同じだが、 ユーザが用意した .I *mntbuf に \fIstruct mount\fP を格納し、その構造体の各エントリが指し示す文字列を ユーザが用意した大きさ .I buflen の配列 .I buf に書き込む。 .PP .\"O The \fImntent\fP structure is defined in \fI\fP as follows: \fImntent\fP 構造体は \fI\fP で以下のように定義されている。 .sp .in +4n .nf 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 */ }; .fi .in .\"O Since fields in the mtab and fstab files are separated by whitespace, .\"O octal escapes are used to represent the four characters space (\e040), .\"O tab (\e011), newline (\e012) and backslash (\e134) in those files .\"O when they occur in one of the four strings in a .\"O .I mntent .\"O structure. .\"O The routines .\"O .BR addmntent () .\"O and .\"O .BR getmntent () .\"O will convert .\"O from string representation to escaped representation and back. mtab や fstab ファイルでは、各フィールドは空白で区切られているので、 スペース、タブ、改行、バックスラッシュの 4文字をこれらのファイルで 使いたい場合で、かつ .I mntent 構造体の 4つの文字列メンバーのいずれかに対応するフィールド内で 使いたい場合には、8進のエスケープ表記を使って表現する: スペース (\e040), タブ (\e011), 改行 (\e012), バックスラッシュ (\e134)。 .BR addmntent () と .BR getmntent () は、文字列表現から エスケープ表現への変換、およびその逆を行う。 .\"O .SH "RETURN VALUE" .SH 返り値 .\"O The .\"O .BR getmntent () .\"O and .\"O .BR getmntent_r () .\"O functions return .\"O a pointer to the .\"O .I mntent .\"O structure or NULL on failure. .BR getmntent () と .BR getmntent_r () は .I mntent 構造体へのポインタを返す。 失敗した場合は NULL を返す。 .PP .\"O The .\"O .BR addmntent () .\"O function returns 0 on success and 1 on failure. .\Baddmntent\fP() 関数は成功したら 0 を返し、失敗したら 1 を返す。 .PP .\"O The .\"O .BR endmntent () .\"O function always returns 1. .BR endmntent () 関数はつねに 1 を返す。 .PP .\"O The .\"O .BR hasmntopt () .\"O function returns the address of the substring if .\"O a match is found and NULL otherwise. .BR hasmntopt () 関数は、マッチした場合は部分文字列へのアドレスを返し、 マッチしなければ NULL を返す。 .\"O .SH FILES .SH ファイル .nf .\"O /etc/fstab file system description file .\"O /etc/mtab mounted file system description file /etc/fstab ファイルシステム記述ファイル /etc/mtab マウントされたファイルシステムの記述ファイル .fi .\"O .SH "CONFORMING TO" .SH 準拠 .\"O The nonreentrant functions are from SunOS 4.1.3. .\"O A routine .\"O .BR getmntent_r () .\"O was introduced in HP-UX 10, but it returns an int. .\"O The prototype shown above is glibc-only. リエントラントでない関数は SunOS 4.1.3 由来のものである。 .BR getmntent_r () 関数は HPUX 10 で導入されたが、このバージョンでは int を返す。 上記に示したプロトタイプは glibc 独自のものである。 .\"O .SH NOTES .SH 注意 .\"O System V also has a .\"O .BR getmntent () .\"O function but the calling sequence .\"O differs, and the returned structure is different. .\"O Under System V .\"O .I /etc/mnttab .\"O is used. System V にも .BR getmntent () 関数はあるが、 呼び出し手順が異なり、返される構造体も異なる。 System V では .I /etc/mnttab が用いられる。 .\"O 4.4BSD and Digital Unix have a routine .\"O .BR getmntinfo (), .\"O a wrapper around the system call .\"O .BR getfsstat (). 4.4BSD と Digital Unix には .BR getmntinfo () があるが、 システムコール .BR getfsstat () のラッパー関数である。 .\"O .SH "SEE ALSO" .SH 関連項目 .BR fopen (3), .BR fstab (5), .BR mount (8)