diff options
Diffstat (limited to 'documentation/manual-pages/ja/man5/dir.5')
-rw-r--r-- | documentation/manual-pages/ja/man5/dir.5 | 171 |
1 files changed, 171 insertions, 0 deletions
diff --git a/documentation/manual-pages/ja/man5/dir.5 b/documentation/manual-pages/ja/man5/dir.5 new file mode 100644 index 0000000000..33ca668cea --- /dev/null +++ b/documentation/manual-pages/ja/man5/dir.5 @@ -0,0 +1,171 @@ +.\" Copyright (c) 1983, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)dir.5 8.3 (Berkeley) 4/19/94 +.\" %FreeBSD: src/share/man/man5/dir.5,v 1.20 2003/09/10 19:24:35 ru Exp % +.\" +.\" $FreeBSD$ +.\" +.\" WORD: graft 接合 [mount.8] +.Dd April 19, 1994 +.Dt DIR 5 +.Os +.Sh 名称 +.Nm dir , +.Nm dirent +.Nd ディレクトリファイルフォーマット +.Sh 書式 +.In dirent.h +.Sh 解説 +ディレクトリは、土台となる記憶媒体の詳細を隠蔽し、 +ファイルをグループ分けする便利な階層手段を提供します。 +ディレクトリファイルは、その +.Xr inode 5 +エントリ中のフラグによって、通常ファイルと区別されます。 +ディレクトリファイルはレコード (ディレクトリエントリ) から構成され、 +各レコードはファイルに関する情報とそのファイル自身へのポインタを +含んでいます。 +ディレクトリエントリは、通常ファイルと同様に、 +他のディレクトリを含むこともあります。 +そのような入れ子になったディレクトリはサブディレクトリと呼ばれます。 +このようにしてディレクトリとファイルの階層構造が形成され、 +この構造はファイルシステムと呼ばれます (あるいはファイルシステムツリー +と呼ばれます)。 +.\" 以下の3行は英語版にコメントの形で含まれていたもの +.\" An entry in this tree, +.\" nested or not nested, +.\" is a pathname. +.Pp +各ディレクトリファイルには特別なディレクトリエントリが 2 つあります。 +1 つはそのディレクトリ自身へのポインタで、ドット +.Ql .\& +と呼ばれます。 +もう 1 つは自分の親ディレクトリへのポインタで、ドットドット +.Ql \&..\& +と呼ばれます。 +ドットとドットドットは有効なパス名ですが、 +システムのルートディレクトリ +.Ql / +には親ディレクトリがなく、ドットドットはドットと同じく自分自身を指します。 +.Pp +ファイルシステムノードは普通のディレクトリファイルであり、 +その上に物理ディスクやそのディスク中の分割された領域といった +ファイルシステムオブジェクトを接合します +( +.Xr mount 2 +および +.Xr mount 8 +参照)。 +.Pp +ディレクトリエントリの形式はファイル +.In sys/dirent.h +で定義されています +(これは直接アプリケーションからはインクルードされません): +.Bd -literal +#ifndef _SYS_DIRENT_H_ +#define _SYS_DIRENT_H_ + +#include <machine/ansi.h> + +/* + * dirent 構造体は、getdirentries(2) システムコールで返される + * ディレクトリエントリのフォーマットを定義します。 + * + * ディレクトリエントリはその先頭に dirent 構造体を持ちます。dirent + * 構造体は inode 番号、そのエントリの長さ、そのエントリに含まれる + * 名前の長さを保持します。その後に、ナルで 4 バイト境界までパディング + * した名前が続きます。名前は全てナルで終端していることが保証されます。 + * ディレクトリ中の名前の長さの最大値は MAXNAMLEN です。 + */ + +struct dirent { + __uint32_t d_fileno; /* エントリのファイル番号 */ + __uint16_t d_reclen; /* このレコードの長さ */ + __uint8_t d_type; /* ファイルタイプ、以下参照 */ + __uint8_t d_namlen; /* d_name の文字列長 */ +#ifdef _POSIX_SOURCE + char d_name[255 + 1]; /* 名前はこの長さを越えてはならない */ +#else +#define MAXNAMLEN 255 + char d_name[MAXNAMLEN + 1]; /* 名前はこの長さを越えてはならない */ +#endif + +}; + +/* + * ファイルタイプ + */ +#define DT_UNKNOWN 0 +#define DT_FIFO 1 +#define DT_CHR 2 +#define DT_DIR 4 +#define DT_BLK 6 +#define DT_REG 8 +#define DT_LNK 10 +#define DT_SOCK 12 +#define DT_WHT 14 + +/* + * stat 構造体型とディレクトリ型との変換 + */ +#define IFTODT(mode) (((mode) & 0170000) >> 12) +#define DTTOIF(dirtype) ((dirtype) << 12) + +/* + * _GENERIC_DIRSIZ マクロはディレクトリエントリを保持する最小レコード長を + * 与えます。これは d_name フィールド以外の dirent 構造体の空間に、ナル + * バイトで終端される名前のために十分な空間 (dp->d_namlen+1) を加えたもの + * を、4 バイト単位で繰り上げたものです。 + */ +#define _GENERIC_DIRSIZ(dp) \ + ((sizeof (struct dirent) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3)) + +#ifdef _KERNEL +#define GENERIC_DIRSIZ(dp) _GENERIC_DIRSIZ(dp) +#endif + +#endif /* !_SYS_DIRENT_H_ */ +.Ed +.Sh 関連項目 +.Xr fs 5 , +.Xr inode 5 +.Sh バグ +struct dirent のメンバ d_type は +.Fx +固有であり、 +使用はポータブルではありません。 +また、特定のファイルシステム、例えば cd9660 ファイルシステムでは失敗します。 +.Sh 歴史 +ファイル形式 +.Nm +は +.At v7 +で登場しました。 |