1 .\" Copyright (C) 1993 David Metcalfe (david@prism.demon.co.uk)
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" References consulted:
24 .\" Linux libc source code
25 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
27 .\" Modified Sat Jul 24 16:09:49 1993 by Rik Faith (faith@cs.unc.edu)
28 .\" Modified 11 June 1995 by Andries Brouwer (aeb@cwi.nl)
29 .\" Modified 22 July 1996 by Andries Brouwer (aeb@cwi.nl)
30 .\" 2007-07-30 Ulrich Drepper <drepper@redhat.com>, mtk:
31 .\" Rework discussion of nonstandard structure fields.
32 .\" 2008-09-11, mtk, Document readdir_r().
34 .\" Japanese Version Copyright (c) 1997 HIROFUMI Nishizuka
35 .\" all rights reserved.
36 .\" Translated 1997-12-24, HIROFUMI Nishizuka <nishi@rpts.cl.nec.co.jp>
37 .\" Updated & Modified 2002-03-24, Yuichi SATO <ysato@h4.dion.ne.jp>
38 .\" Updated & Modified 2005-01-16, Yuichi SATO <ysato444@yahoo.co.jp>
39 .\" Updated & Modified 2005-09-06, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
40 .\" Updated 2008-08-11, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.05
42 .TH READDIR 3 2010-09-10 "" "Linux Programmer's Manual"
44 readdir, readdir_r \- ¥Ç¥£¥ì¥¯¥È¥ê¤òÆɤ߹þ¤à
47 .B #include <dirent.h>
49 .BI "struct dirent *readdir(DIR *" dirp );
51 .BI "int readdir_r(DIR *" dirp ", struct dirent *" entry \
52 ", struct dirent **" result );
56 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
57 .RB ( feature_test_macros (7)
64 _POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _BSD_SOURCE ||
65 _SVID_SOURCE || _POSIX_SOURCE
70 ´Ø¿ô¤Ï¡¢\fIdirp\fP ¤¬»Ø¤¹¥Ç¥£¥ì¥¯¥È¥ê¥¹¥È¥ê¡¼¥à¤ÎÃæ¤Ç¡¢
71 ¼¡¤Î¥Ç¥£¥ì¥¯¥È¥ê¥¨¥ó¥È¥ê¤òɽ¤¹ \fIdirent\fP ¹½Â¤ÂΤؤΥݥ¤¥ó¥¿¤òÊÖ¤¹¡£
72 ¥Ç¥£¥ì¥¯¥È¥ê¥¹¥È¥ê¡¼¥à¤ÎËöÈø¤Ë㤷¤¿¾ì¹ç¤ä¡¢
73 ¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤Ï¡¢ NULL ¤òÊÖ¤¹¡£
77 ¹½Â¤ÂΤϰʲ¼¤Î¤è¤¦¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡£
82 ino_t d_ino; /* inode ÈÖ¹æ */
83 off_t d_off; /* ¼¡¤Î dirent ¤Ø¤Î¥ª¥Õ¥»¥Ã¥È */
84 unsigned short d_reclen; /* ¤³¤Î¥ì¥³¡¼¥É¤ÎŤµ */
85 unsigned char d_type; /* ¥Õ¥¡¥¤¥ë¼ïÊÌ¡£Á´¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à */
86 ¤Ç¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤ë¤ï¤±¤Ç¤Ï¤Ê¤¤ */
87 char d_name[256]; /* ¥Õ¥¡¥¤¥ë̾ */
93 ¹½Â¤ÂΤΥե£¡¼¥ë¥É¤Ç POSIX.1 ¤ÇÍ׵ᤵ¤ì¤Æ¤¤¤ë¤Î¤Ï¡¢
99 ¤Ï¤½¤ÎÂ礤µ¤âµ¬Äꤵ¤ì¤Æ¤ª¤é¤º¡¢
100 ¤³¤Î¥Õ¥£¡¼¥ë¥É¤Ë¤ÏºÇÂç¤Ç
102 ¸Ä¤Îʸ»ú¤È¡¢¤½¤ì¤Ë³¤¯½ªÃ¼¤Î NULL ¥Ð¥¤¥È¤¬³ÊǼ¤µ¤ì¤ë¡£
103 ¾¤Î¥Õ¥£¡¼¥ë¥É¤ÏÈóɸ½à¤Ç¤¢¤ê¡¢Á´¤Æ¤Î¥·¥¹¥Æ¥à¤Ë¸ºß¤¹¤ë¤ï¤±¤Ç¤Ï¤Ê¤¤¡£
104 ¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï¡¢²¼µ¤Î¡ÖÃí°Õ¡×¤ò»²¾È¤Î¤³¤È¡£
107 ¤Ë¤è¤Ã¤ÆÊÖ¤µ¤ì¤ë¥Ç¡¼¥¿¤Ï¡¢¤½¤ì°Ê¹ß¤ÎƱ¤¸¥¹¥È¥ê¡¼¥à¤ËÂФ¹¤ë
109 ¤Î¸Æ¤Ó½Ð¤·¤Ë¤è¤Ã¤Æ¾å½ñ¤¤µ¤ì¤ë²ÄǽÀ¤¬¤¢¤ë¡£
114 ¤Î¥ê¥¨¥ó¥È¥é¥ó¥ÈÈǤǤ¢¤ë¡£
115 ¤³¤Î´Ø¿ô¤Ï¥Ç¥£¥ì¥¯¥È¥ê¥¹¥È¥ê¡¼¥à
117 ¤«¤é¼¡¤Î¥Ç¥£¥ì¥¯¥È¥ê¥¨¥ó¥È¥ê¤òÆɤ߹þ¤ß¡¢
119 ¤¬»Ø¤¹¸Æ¤Ó½Ð¤·¸µ¤¬³ä¤êÅö¤Æ¤¿¥Ð¥Ã¥Õ¥¡¤Ë¤½¤Î¥¨¥ó¥È¥ê¤ò³ÊǼ¤·¤ÆÊÖ¤¹
120 (¤³¤Î¥Ð¥Ã¥Õ¥¡¤Î³ä¤êÅö¤Æ¤Ë¤Ä¤¤¤Æ¤Ï¡ÖÃí°Õ¡×¤ÎÀá¤ò»²¾È¤Î¤³¤È)¡£
121 ÊÖ¤µ¤ì¤ë¥¨¥ó¥È¥ê¤Ø¤Î¥Ý¥¤¥ó¥¿¤¬
123 ¤Ë³ÊǼ¤µ¤ì¤ë¡£¥Ç¥£¥ì¥¯¥È¥ê¥¹¥È¥ê¡¼¥à¤ÎËöÈø¤Ë㤷¤¿¾ì¹ç¤Ï¡¢
132 ¹½Â¤ÂΤؤΥݥ¤¥ó¥¿¤òÊÖ¤¹¡£
133 (¤³¤Î¹½Â¤ÂΤÏÀÅŪ¤Ë³ä¤êÅö¤Æ¤é¤ì¤Æ¤¤¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
136 ¤·¤è¤¦¤È¤·¤Ê¤¤¤³¤È¡£)
137 ¥Ç¥£¥ì¥¯¥È¥ê¥¹¥È¥ê¡¼¥à¤ÎËöÈø¤Ë㤷¤¿¾ì¹ç¤Ë¤Ï¡¢NULL ¤¬ÊÖ¤µ¤ì¡¢
140 ¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¡¢NULL ¤¬ÊÖ¤µ¤ì¡¢
147 ¥¨¥é¡¼¤Î¾ì¹ç¡¢(¡Ö¥¨¥é¡¼¡×¤ÎÀá¤Î¥ê¥¹¥È¤ËºÜ¤Ã¤Æ¤¤¤ë) Àµ¤Î¥¨¥é¡¼ÈÖ¹æ¤òÊÖ¤¹¡£
148 ¥Ç¥£¥ì¥¯¥È¥ê¥¹¥È¥ê¡¼¥à¤ÎËöÈø¤Ë㤷¤¿¾ì¹ç¡¢
150 ¤ÏÊÖ¤êÃͤȤ·¤Æ 0 ¤òÊÖ¤·¡¢
156 ¥Ç¥£¥ì¥¯¥È¥ê¥¹¥È¥ê¡¼¥à¥Ç¥£¥¹¥¯¥ê¥×¥¿ \fIdirp\fP ¤¬Ìµ¸ú¡£
158 SVr4, 4.3BSD, POSIX.1-2001.
164 ¤À¤±¤¬ POSIX.1-2001 ¤Çµ¬Äꤵ¤ì¤Æ¤¤¤ë¡£
165 »Ä¤ê¤Î¥Õ¥£¡¼¥ë¥É¤Ï¿¤¯¤Î¥·¥¹¥Æ¥à¤Ë¸ºß¤¹¤ë¤¬¡¢Á´¤Æ¤Î¥·¥¹¥Æ¥à¤Ë
166 ¸ºß¤¹¤ë¤ï¤±¤Ç¤Ï¤Ê¤¤¡£
167 glibc ¤Ç¤Ï¡¢¥×¥í¥°¥é¥à¤¬ POSIX.1 ¤ÇÄêµÁ¤µ¤ì¤Æ¤¤¤Ê¤¤¥Õ¥£¡¼¥ë¥É¤¬
168 ÍøÍѤǤ¤ë¤«¤ò¥Á¥§¥Ã¥¯¤¹¤ë¤³¤È¤¬¤Ç¤¤ë¡£
169 ¥Á¥§¥Ã¥¯¤¹¤ë¤Ë¤Ï¡¢¥Þ¥¯¥í
170 .BR _DIRENT_HAVE_D_NAMLEN ,
171 .BR _DIRENT_HAVE_D_RECLEN ,
172 .BR _DIRENT_HAVE_D_OFF ,
173 .B _DIRENT_HAVE_D_TYPE
174 ¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤«¤ò¥Æ¥¹¥È¤¹¤ì¤Ð¤è¤¤¡£
177 ¥Õ¥£¡¼¥ë¥É¤Ï¡¢Linux °Ê³°¤Ç¤Ï¡¢
178 ¼ç¤Ë BSD ·Ï¤Î¥·¥¹¥Æ¥à¤Ë¤À¤±Â¸ºß¤¹¤ë¡£
179 ¤³¤Î¥Õ¥£¡¼¥ë¥É¤ò»È¤¦¤È¡¢
180 ¤½¤Î¸å¤ÎÆ°ºî¤¬¥Õ¥¡¥¤¥ë¤Î¼ïÊ̤ˤè¤ê·è¤Þ¤ë¾ì¹ç¤Ë¡¢
182 ¤ò¸Æ¤Ó½Ð¤¹¥³¥¹¥È¤òÈò¤±¤ë¤³¤È¤¬¤Ç¤¤ë¡£
185 ¤¬ÄêµÁ¤µ¤ì¤¿¾ì¹ç¡¢glibc ¤Ï
187 ¤ÇÊÖ¤µ¤ì¤ëÃͤȤ·¤Æ°Ê²¼¤Î¥Þ¥¯¥íÄê¿ô¤òÄêµÁ¤¹¤ë¡£
190 ¥Ö¥í¥Ã¥¯¡¦¥Ç¥Ð¥¤¥¹¤Ç¤¢¤ë¡£
193 ¥¥ã¥é¥¯¥¿¡¦¥Ç¥Ð¥¤¥¹¤Ç¤¢¤ë¡£
199 ̾Á°ÉÕ¤¥Ñ¥¤¥× (FIFO) ¤Ç¤¢¤ë¡£
202 ¥·¥ó¥Ü¥ê¥Ã¥¯¡¦¥ê¥ó¥¯¤Ç¤¢¤ë¡£
205 Ä̾ï¤Î¥Õ¥¡¥¤¥ë¤Ç¤¢¤ë¡£
208 UNIX ¥É¥á¥¤¥ó¥½¥±¥Ã¥È¤Ç¤¢¤ë¡£
211 ¥Õ¥¡¥¤¥ë¥¿¥¤¥×¤¬ÉÔÌÀ¤Ç¤¢¤ë¡£
212 .\" The glibc manual says that on some systems this is the only
215 ¥Õ¥¡¥¤¥ë¼ïÊ̤ò·èÄê¤Ç¤¤Ê¤«¤Ã¤¿¾ì¹ç¤Ë¤Ï¡¢
223 .\" Ʊ¤¸ÀâÌÀʸ¤¬ readdir.2 ¤Ë¤â¤¢¤ë¡£
225 ¤Ç¥Õ¥¡¥¤¥ë¥¿¥¤¥×¤òÊÖ¤¹µ¡Ç½¤¬´°Á´¤Ë¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤ë¤Î¤Ï¡¢
226 ¤¤¤¯¤Ä¤«¤Î¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤Ë¤ª¤¤¤Æ¤Î¤ß¤Ç¤¢¤ë
227 (Btrfs, ext2, ext3, ext4 ¤Ï¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤ë)¡£
228 ¤É¤Î¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤â¡¢
230 ¤¬ÊÖ¤µ¤ì¤¿ºÝ¤ËŬÀڤ˽èÍý¤Ç¤¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
234 ¥Õ¥£¡¼¥ë¥É¤Î¥µ¥¤¥º¤Ïµ¬Äꤵ¤ì¤Æ¤ª¤é¤º¡¢
238 ¤Î¸å¤í¤Ë¾¤ÎÈóɸ½à¤Î¥Õ¥£¡¼¥ë¥É¤¬¤¢¤ë¤«¤â¤·¤ì¤Ê¤¤¤Î¤Ç¡¢
239 °Ü¿¢À¤¬É¬Íפʥ¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ç
243 ¤ËÅϤ¹¥Ð¥Ã¥Õ¥¡¤ò¼¡¤Î¤è¤¦¤Ë¤·¤Æ³ä¤êÅö¤Æ¤ë¤Ù¤¤Ç¤¢¤ë¡£
247 len = offsetof(struct dirent, d_name) +
248 pathconf(dirpath, _PC_NAME_MAX) + 1
249 entryp = malloc(len);
257 ¤Ç¤¢¤ë¤³¤È¤òÍ׵ᤷ¤Æ¤¤¤ë¡£)