Man page - setmntent(3)

Packages contains this manual

Available languages:

en fr pl ja ru ro de

Manual

GETMNTENT

名 前
書 式
説 明
返 り 値
フ ァ イ ル
属 性
準 拠
注 意
関 連 項 目
こ の 文 書 に つ い て

名 前

getmntent, setmntent, addmntent, endmntent, hasmntopt, getmntent_r - フ ァ イ ル シ ス テ ム 記 述 フ ァ イ ル の エ ン ト リ ー を 取 得 す る

書 式

#include <stdio.h>
#include <mntent.h>

FILE *setmntent(const char * filename , const char * type );

struct mntent *getmntent(FILE * stream );

int addmntent(FILE * stream , const struct mntent * mnt );

int endmntent(FILE * streamp );

char *hasmntopt(const struct mntent * mnt , const char * opt );

/* GNU に よ る 拡 張 */
#include <mntent.h>

struct mntent *getmntent_r(FILE * streamp , struct mntent * mntbuf ,
char *
buf , int buflen );

glibc 向 け の 機 能 検 査 マ ク ロ の 要 件 ( feature_test_macros (7) 参 照 ):

getmntent_r ():
Since glibc 2.19:
_DEFAULT_SOURCE
Glibc 2.19 and earlier:
_BSD_SOURCE || _SVID_SOURCE

説 明

こ れ ら の ル ー チ ン は 、 フ ァ イ ル シ ス テ ム を 記 述 し た フ ァ イ ル /etc/fstab と 、 マ ウ ン ト さ れ て い る フ ァ イ ル シ ス テ ム を 記 述 し た フ ァ イ ル /etc/mtab に ア ク セ ス す る た め に 用 い ら れ る 。

The setmntent () function opens the filesystem description file filename and returns a file pointer which can be used by getmntent (). The argument type is the type of access required and can take the same values as the mode argument of fopen (3). The returned stream should be closed using endmntent () rather than fclose (3).

getmntent () 関 数 は stream か ら フ ァ イ ル シ ス テ ム の 記 述 フ ァ イ ル の 次 の 行 を 読 み 込 み 、 読 み 込 ん だ 行 を フ ィ ー ル ド に 分 割 し た 内 容 を 収 め た 構 造 体 へ の ポ イ ン タ ー を 返 す 。 ポ イ ン タ ー は メ モ リ ー の 静 的 な 領 域 を 指 し て お り 、 こ の 領 域 は getmntent () を 次 に 呼 び 出 し た と き に 上 書 き さ れ て し ま う 。

addmntent () 関 数 は mntent 構 造 体 mnt の 内 容 を 、 オ ー プ ン さ れ て い る stream の 最 後 に 追 加 す る 。

endmntent () 関 数 は フ ァ イ ル シ ス テ ム の 記 述 フ ァ イ ル に 関 連 付 け ら れ て い る stream を 閉 じ る 。

hasmntopt () 関 数 は mntent 構 造 体 mnt mnt_opts フ ィ ー ル ド (下 記 参 照 ) を ス キ ャ ン し 、 opt に 一 致 す る 部 分 文 字 列 が あ る か を 調 べ る 。 有 効 な マ ウ ン ト オ プ シ ョ ン に つ い て は <mntent.h> mount (8) を 参 照 の こ と 。

リ エ ン ト ラ ン ト な 関 数 getmntent_r () は getmntent () と 同 じ だ が 、 ユ ー ザ ー が 用 意 し た *mntbuf struct mount を 格 納 し 、 そ の 構 造 体 の 各 エ ン ト リ ー が 指 し 示 す 文 字 列 を ユ ー ザ ー が 用 意 し た 大 き さ buflen の 配 列 buf に 書 き 込 む 。

mntent 構 造 体 は <mntent.h> で 以 下 の よ う に 定 義 さ れ て い る 。

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 */
};

Since fields in the mtab and fstab files are separated by whitespace, octal escapes are used to represent the characters space (\040), tab (\011), newline (\012), and backslash (\\) in those files when they occur in one of the four strings in a mntent structure. The routines addmntent () and getmntent () will convert from string representation to escaped representation and back. When converting from escaped representation, the sequence \134 is also converted to a backslash.

返 り 値

getmntent () と getmntent_r () は mntent 構 造 体 へ の ポ イ ン タ ー を 返 す 。 失 敗 し た 場 合 は NULL を 返 す 。

addmntent () 関 数 は 成 功 し た ら 0 を 返 し 、 失 敗 し た ら 1 を 返 す 。

endmntent () 関 数 は つ ね に 1 を 返 す 。

hasmntopt () 関 数 は 、 マ ッ チ し た 場 合 は 部 分 文 字 列 へ の ア ド レ ス を 返 し 、 マ ッ チ し な け れ ば NULL を 返 す 。

フ ァ イ ル

/etc/fstab

filesystem description file

/etc/mtab

mounted filesystem description file

属 性

こ の 節 で 使 用 さ れ て い る 用 語 の 説 明 に つ い て は 、 attributes (7) を 参 照 。

Image grohtml-39811-1.png

準 拠

リ エ ン ト ラ ン ト で な い 関 数 は SunOS 4.1.3 由 来 の も の で あ る 。 getmntent_r () 関 数 は HPUX 10 で 導 入 さ れ た が 、 こ の バ ー ジ ョ ン で は int を 返 す 。 上 記 に 示 し た プ ロ ト タ イ プ は glibc 独 自 の も の で あ る 。

注 意

System V に も getmntent () 関 数 は あ る が 、 呼 び 出 し 手 順 が 異 な り 、 返 さ れ る 構 造 体 も 異 な る 。 System V で は /etc/mnttab が 用 い ら れ る 。 4.4BSD と Digital UNIX に は getmntinfo () が あ る が 、 シ ス テ ム コ ー ル getfsstat () の ラ ッ パ ー 関 数 で あ る 。

関 連 項 目

fopen (3), fstab (5), mount (8)

こ の 文 書 に つ い て

こ の man ペ ー ジ は Linux man-pages プ ロ ジ ェ ク ト の リ リ ー ス 5.10 の 一 部 で あ る 。 プ ロ ジ ェ ク ト の 説 明 と バ グ 報 告 に 関 す る 情 報 は https://www.kernel.org/doc/man-pages/ に 書 か れ て い る 。