OSDN Git Service

61681e94cd485b5d85be5fdb95730b50dc1ca309
[linuxjm/LDP_man-pages.git] / draft / man2 / readdir.2
1 .\" Copyright (C) 1995 Andries Brouwer (aeb@cwi.nl)
2 .\"
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.
6 .\"
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.
11 .\"
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
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" Written 11 June 1995 by Andries Brouwer <aeb@cwi.nl>
24 .\" Modified 22 July 1995 by Michael Chastain <mec@duracef.shout.net>:
25 .\"   In 1.3.X, returns only one entry each time; return value is different.
26 .\" Modified 2004-12-01, mtk, fixed headers listed in SYNOPSIS
27 .\"
28 .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
29 .\"         all rights reserved.
30 .\" Translated Sun Feb 23 21:06:24 JST 1997
31 .\"         by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
32 .\"
33 .\"WORD:        directory               ¥Ç¥£¥ì¥¯¥È¥ê
34 .\"WORD:        entry                   ¥¨¥ó¥È¥ê
35 .\"WORD:        kernel                  ¥«¡¼¥Í¥ë
36 .\"WORD:        system call             ¥·¥¹¥Æ¥à¡¦¥³¡¼¥ë
37 .\"WORD:        memory                  ¥á¥â¥ê
38 .\"WORD:        inode number            inode ÈÖ¹æ
39 .\"WORD:        null                    ¥Ì¥ëʸ»ú
40 .\"
41 .TH READDIR 2  2008-10-02 "Linux" "Linux Programmer's Manual"
42 .\"O .SH NAME
43 .SH Ì¾Á°
44 .\"O readdir \- read directory entry
45 readdir \- ¥Ç¥£¥ì¥¯¥È¥ê¡¦¥¨¥ó¥È¥ê¤òÆɤ߹þ¤à
46 .\"O .SH SYNOPSIS
47 .SH ½ñ¼°
48 .nf
49 .sp
50 .BI "int readdir(unsigned int " fd ", struct old_linux_dirent *" dirp ","
51 .BI "            unsigned int " count );
52 .fi
53 .\"O .SH DESCRIPTION
54 .SH ÀâÌÀ
55 .\"O This is not the function you are interested in.
56 .\"O Look at
57 .\"O .BR readdir (3)
58 .\"O for the POSIX conforming C library interface.
59 .\"O This page documents the bare kernel system call interface,
60 .\"O which is superseded by
61 .\"O .BR getdents (2).
62 ¤³¤ì¤Ï¤¢¤Ê¤¿¤Î¶½Ì£¤ò¤â¤Ã¤Æ¤¤¤ë´Ø¿ô¤Ç¤Ï¤Ê¤¤¡£
63 POSIX ½àµò¤Î C ¥é¥¤¥Ö¥é¥ê¡¦¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹¤Ë¤Ä¤¤¤Æ¤Ï
64 .BR readdir (3)
65 ¤ò¸«¤ë¤³¤È¡£
66 ¤³¤Î¥Ú¡¼¥¸¤ÏÍç¤Î¥«¡¼¥Í¥ë¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¡¦¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹¤Ë¤Ä¤¤¤Æ
67 µ­½Ò¤·¤Æ¤¤¤ë¤¬¡¢¤³¤Î¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹¤Ï
68 .BR getdents (2)
69 ¤Ë¤è¤Ã¤Æ¼è¤Ã¤ÆÂå¤ï¤é¤ì¤¿¡£
70 .PP
71 .\"O .BR readdir ()
72 .\"O reads one
73 .\"O .I old_linux_dirent
74 .\"O structure from the directory
75 .\"O referred to by the file descriptor
76 .\"O .I fd
77 .\"O into the buffer pointed to by
78 .\"O .IR dirp .
79 .\"O The argument
80 .\"O .I count
81 .\"O is ignored; at most one
82 .\"O .I old_linux_dirent
83 .\"O structure is read.
84 .BR readdir ()
85 ¤Ï¡¢¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿
86 .I fd
87 ¤¬»²¾È¤·¤Æ¤¤¤ë¥Ç¥£¥ì¥¯¥È¥ê¤«¤é
88 .I old_linux_dirent
89 ¹½Â¤ÂΤòÆɤ߹þ¤ß¡¢
90 .I dirp
91 ¤Ç»Ø¤µ¤ì¤¿¥Ð¥Ã¥Õ¥¡¤Ë³ÊǼ¤¹¤ë¡£
92 .I count
93 °ú¤­¿ô¤Ï(¤Û¤È¤ó¤É¤Î
94 .I old_linux_dirent
95 ¹½Â¤ÂΤÎÆɤ߹þ¤ß¤Ë¤ª¤¤¤Æ)̵»ë¤µ¤ì¤ë
96 .PP
97 .\"O The
98 .\"O .I old_linux_dirent
99 .\"O structure is declared as follows:
100 .I old_linux_dirent
101 ¹½Â¤ÂΤϰʲ¼¤Î¤è¤¦¤ËÀë¸À¤µ¤ì¤ë:
102 .PP
103 .in +4n
104 .nf
105 struct old_linux_dirent {
106     long  d_ino;              /* inode number */
107     off_t d_off;              /* offset to this \fIold_linux_dirent\fP */
108     unsigned short d_reclen;  /* length of this \fId_name\fP */
109     char  d_name[NAME_MAX+1]; /* filename (null-terminated) */
110 }
111 .fi
112 .in
113 .PP
114 .\"O .I d_ino
115 .\"O is an inode number.
116 .\"O .I d_off
117 .\"O is the distance from the start of the directory to this
118 .\"O .IR old_linux_dirent .
119 .\"O .I d_reclen
120 .\"O is the size of
121 .\"O .IR d_name ,
122 .\"O not counting the null terminator.
123 .\"O .I d_name
124 .\"O is a null-terminated filename.
125 .I d_ino
126 ¤Ï inode ÈÖ¹æ¤Ç¤¢¤ë¡£
127 .I d_off
128 ¤Ï¥Ç¥£¥ì¥¯¥È¥ê¤ÎºÇ½é¤«¤é¤³¤Î
129 .I old_linux_dirent
130 ¤Þ¤Çµ÷Î¥¤Ç¤¢¤ë¡£
131 .I d_reclen
132 ¤Ï
133 .I d_name
134 ¤ÎÂ礭¤µ¤Ç¡¢
135 ¥Ì¥ëʸ»ú¤Î½ªÃ¼¤ò´Þ¤ó¤Ç¤¤¤Ê¤¤¡£
136 .I d_name
137 ¤Ï¥Ì¥ëʸ»ú¤Ç½ª¤ë¥Õ¥¡¥¤¥ë̾¤Ç¤¢¤ë¡£
138 .\"O .SH "RETURN VALUE"
139 .SH ÊÖ¤êÃÍ
140 .\"O On success, 1 is returned.
141 .\"O On end of directory, 0 is returned.
142 .\"O On error, \-1 is returned, and
143 .\"O .I errno
144 .\"O is set appropriately.
145 À®¸ù¤·¤¿¾ì¹ç¤Ï¡¢1 ¤¬ÊÖ¤µ¤ì¤ë¡£
146 ¥Ç¥£¥ì¥¯¥È¥ê¤ÎºÇ¸å¤Ç¤Ï 0 ¤¬ÊÖ¤µ¤ì¤ë¡£
147 ¥¨¥é¡¼¤Î¾ì¹ç¤Ï \-1 ¤¬ÊÖ¤µ¤ì¡¢
148 .I errno
149 ¤¬Å¬ÀÚ¤ËÀßÄꤵ¤ì¤ë¡£
150 .\"O .SH ERRORS
151 .SH ¥¨¥é¡¼
152 .TP
153 .B EBADF
154 .\"O Invalid file descriptor
155 .\"O .IR fd .
156 ¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼
157 .I fd
158 ¤¬ÉÔÀµ¤Ç¤¢¤ë¡£
159 .TP
160 .B EFAULT
161 .\"O Argument points outside the calling process's address space.
162 °ú¤­¿ô¤Î¥Ý¥¤¥ó¥¿¡¼¤¬¸Æ¤Ó½Ð¤·¤¿¥×¥í¥»¥¹¤¬¥¢¥¯¥»¥¹²Äǽ¤Ê¶õ´Ö¤Î
163 ³°Éô¤ò»Ø¤·¤Æ¤¤¤ë¡£
164 .TP
165 .B EINVAL
166 .\"O Result buffer is too small.
167 ·ë²ÌÍѤΥХåե¡¡¼¤¬¾®¤µ²á¤®¤ë¡£
168 .TP
169 .B ENOENT
170 .\"O No such directory.
171 ¤½¤Î¤è¤¦¤Ê¥Ç¥£¥ì¥¯¥È¥ê¤Ï¸ºß¤·¤Ê¤¤¡£
172 .TP
173 .B ENOTDIR
174 .\"O File descriptor does not refer to a directory.
175 ¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼¤¬¥Ç¥£¥ì¥¯¥È¥ê¤ò»²¾È¤·¤Æ¤¤¤Ê¤¤¡£
176 .\"O .SH "CONFORMING TO"
177 .SH ½àµò
178 .\"O This system call is Linux-specific.
179 ¤³¤Î¥·¥¹¥Æ¥à¡¦¥³¡¼¥ë¤Ï Linux ÆÃÍ­¤Ç¤¢¤ë¡£
180 .\"O .SH NOTES
181 .SH Ãí°Õ
182 .\"O Glibc does not provide a wrapper for this system call; call it using
183 .\"O .BR syscall (2).
184 glibc ¤Ï¤³¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤ËÂФ¹¤ë¥é¥Ã¥Ñ¡¼´Ø¿ô¤òÄ󶡤·¤Æ¤¤¤Ê¤¤¡£
185 .BR syscall (2)
186 ¤ò»È¤Ã¤Æ¸Æ¤Ó½Ð¤¹¤³¤È¡£
187 .\"O You will need to define the
188 .\"O .I old_linux_dirent
189 .\"O structure yourself.
190 .I old_linux_dirent
191 ¹½Â¤ÂΤò¼«Ê¬¼«¿È¤ÇÄêµÁ¤¹¤ëɬÍפ¬¤¢¤ë¡£
192 .\"O .SH "SEE ALSO"
193 .SH ´ØÏ¢¹àÌÜ
194 .BR getdents (2),
195 .BR readdir (3)