.\" Copyright (C) 1995 Andries Brouwer (aeb@cwi.nl) .\" .\" %%%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 .\" .\" Written 11 June 1995 by Andries Brouwer .\" Modified 22 July 1995 by Michael Chastain : .\" In 1.3.X, returns only one entry each time; return value is different. .\" Modified 2004-12-01, mtk, fixed headers listed in SYNOPSIS .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya .\" all rights reserved. .\" Translated Sun Feb 23 21:06:24 JST 1997 .\" by HANATAKA Shinya .\" Updated 2013-05-01, Akihiro MOTOKI .\" Updated 2013-07-22, Akihiro MOTOKI .\" .TH READDIR 2 2019\-03\-06 Linux "Linux Programmer's Manual" .SH 名前 readdir \- ディレクトリエントリーを読み込む .SH 書式 .nf .PP \fBint readdir(unsigned int \fP\fIfd\fP\fB, struct old_linux_dirent *\fP\fIdirp\fP\fB,\fP \fB unsigned int \fP\fIcount\fP\fB);\fP .fi .PP \fI注\fP: このシステムコールには glibc のラッパー関数は存在しない。「注意」の節を参照。 .SH 説明 これはあなたの関心を引くような関数ではないだろう。 POSIX 準拠の C ライブラリインターフェースについては \fBreaddir\fP(3) を参照のこと。このページでは、生のカーネルのシステムコールインターフェースについて記載しているが、このインターフェースは \fBgetdents\fP(2) によって置き換えられた。 .PP \fBreaddir\fP() は、ファイルディスクリプター \fIfd\fP が参照しているディレクトリから \fIold_linux_dirent\fP 構造体をひとつ読み込み、 \fIdirp\fP で指されたバッファーに格納する。 \fIcount\fP 引数は無視される。最大で 1 個の \fIold_linux_dirent\fP 構造体が読み出される。 .PP \fIold_linux_dirent\fP 構造体は (Linux カーネルのファイル \fBfs/readdir.c\fP で内部用として) 以下のように宣言される: .PP .in +4n .EX struct old_linux_dirent { unsigned long d_ino; /* inode 番号 */ unsigned long d_offset; /* この \fIold_linux_dirent\fP へのオフセット */ unsigned short d_namlen; /* この \fId_name\fP の長さ */ char d_name[1]; /* (NULL 終端された) ファイル名 */ } .EE .in .PP \fId_ino\fP は inode 番号である。 \fId_offset\fP はディレクトリの最初からこの \fIold_linux_dirent\fP までの距離である。 \fId_reclen\fP は \fId_name\fP の大きさで、終端のヌルバイト (\(aq\e0\(aq) を含まない。 \fId_name\fP はヌルで終端されたファイル名である。 .SH 返り値 成功した場合は、1 が返される。 ディレクトリの最後では 0 が返される。 エラーの場合は \-1 が返され、 \fIerrno\fP が適切に設定される。 .SH エラー .TP \fBEBADF\fP ファイルディスクリプター \fIfd\fP が不正である。 .TP \fBEFAULT\fP 引数が呼び出し元プロセスのアドレス空間外を指している。 .TP \fBEINVAL\fP 結果用のバッファーが小さすぎる。 .TP \fBENOENT\fP そのようなディレクトリは存在しない。 .TP \fBENOTDIR\fP ファイルディスクリプターがディレクトリを参照していない。 .SH 準拠 このシステムコールは Linux 固有である。 .SH 注意 glibc はこのシステムコールに対するラッパー関数を提供していない。 \fBsyscall\fP(2) を使って呼び出すこと。 \fIold_linux_dirent\fP 構造体を自分自身で定義する必要がある。しかし、たいていはこのシステムコールではなく \fBreaddir\fP(3) を使うべき場面のことが多い。 .PP このシステムコールは x86\-64 では存在しない。 .SH 関連項目 \fBgetdents\fP(2), \fBreaddir\fP(3) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は \%https://www.kernel.org/doc/man\-pages/ に書かれている。