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 18:46:01 1993 by Rik Faith (faith@cs.unc.edu)
28 .\" Modified 11 June 1995 by Andries Brouwer (aeb@cwi.nl).
29 .\" 2007-07-30 Ulrich Drepper <drepper@redhat.com>: document fdopendir().
31 .\" Japanese Version Copyright (c) 1997 Seiichi Yoshida
32 .\" all rights reserved.
33 .\" Translated Fri Feb 14 14:53:20 JST 1997
34 .\" by Seiichi Yoshida <seiichi@muraoka.info.waseda.ac.jp>
35 .\" Updated & Modified Thu Feb 17 00:37:46 JST 2005
36 .\" by Yuichi SATO <ysato444@yahoo.co.jp>
38 .\"WORD: directory stream ¥Ç¥£¥ì¥¯¥È¥ê¥¹¥È¥ê¡¼¥à
39 .\"WORD: entry ¥¨¥ó¥È¥ê
40 .\"WORD: Permission denied ¥¢¥¯¥»¥¹¸¢¸Â¤¬¤Ê¤¤
41 .\"WORD: file descriptor ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿
43 .TH OPENDIR 3 2010-06-20 "" "Linux Programmer's Manual"
46 .\"O opendir, fdopendir \- open a directory
47 opendir, fdopendir \- ¥Ç¥£¥ì¥¯¥È¥ê¤ò¥ª¡¼¥×¥ó¤¹¤ë
51 .B #include <sys/types.h>
53 .B #include <dirent.h>
55 .BI "DIR *opendir(const char *" name );
56 .BI "DIR *fdopendir(int " fd );
60 .\"O Feature Test Macro Requirements for glibc (see
61 .\"O .BR feature_test_macros (7)):
62 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
63 .RB ( feature_test_macros (7)
72 .\"O Since glibc 2.10:
74 _XOPEN_SOURCE\ >=\ 700 || _POSIX_C_SOURCE\ >=\ 200809L
76 .\"O Before glibc 2.10:
86 .\"O function opens a directory stream corresponding to the
87 .\"O directory \fIname\fP, and returns a pointer to the directory stream.
88 .\"O The stream is positioned at the first entry in the directory.
90 ´Ø¿ô¤Ï¥Ç¥£¥ì¥¯¥È¥ê \fIname\fP ¤ËÂбþ¤¹¤ë
91 ¥Ç¥£¥ì¥¯¥È¥ê¥¹¥È¥ê¡¼¥à¤ò¥ª¡¼¥×¥ó¤·¡¢¤½¤Î¥¹¥È¥ê¡¼¥à¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£
92 ¥¹¥È¥ê¡¼¥à¤Î°ÌÃ֤ϥǥ£¥ì¥¯¥È¥ê¤ÎÀèƬ¤Î¥¨¥ó¥È¥ê¤ËÀßÄꤵ¤ì¤ë¡£
99 .\"O but returns a directory stream for the directory referred
100 .\"O to by the open file descriptor
102 .\"O After a successful call to
103 .\"O .BR fdopendir (),
105 .\"O is used internally by the implementation,
106 .\"O and should not otherwise be used by the application.
110 ¤ÈƱÍͤÀ¤¬¡¢¥ª¡¼¥×¥óºÑ¤ß¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿
112 ¤Ë¤è¤ê»²¾È¤µ¤ì¤ë¥Ç¥£¥ì¥¯¥È¥ê¤ËÂФ¹¤ë
113 ¥Ç¥£¥ì¥¯¥È¥ê¥¹¥È¥ê¡¼¥à¤òÊÖ¤¹¡£
115 ¤Î¸Æ¤Ó½Ð¤·¤¬À®¸ù¤·¤¿¸å¤Ï¡¢
117 ¤Ï¼ÂÁõ¤ÎÆâÉô¤Ç»ÈÍѤµ¤ì¤ë¡£¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï
119 ¤ò¾¤Î¾ìÌ̤ǻÈÍѤ¹¤Ù¤¤Ç¤Ï¤Ê¤¤¡£
120 .\"O .SH "RETURN VALUE"
125 .\"O .BR fdopendir ()
126 .\"O functions return a pointer to the directory stream.
127 .\"O On error, NULL is returned, and
129 .\"O is set appropriately.
134 ¤Ï¥Ç¥£¥ì¥¯¥È¥ê¥¹¥È¥ê¡¼¥à¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£
135 ¥¨¥é¡¼¤Î¾ì¹ç¤Ï¡¢NULL ¤¬ÊÖ¤µ¤ì¤Æ¡¢
142 .\"O Permission denied.
147 .\"O is not a valid file descriptor opened for reading.
149 ¤¬Æɤ߽Ф·ÍѤ˥ª¡¼¥×¥ó¤µ¤ì¤¿¡¢Í¸ú¤Ê¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ç¤Ï¤Ê¤¤¡£
152 .\"O Too many file descriptors in use by process.
153 ¥×¥í¥»¥¹¤¬»ÈÍÑÃæ¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤¬Â¿¤¹¤®¤ë¡£
156 .\"O Too many files are currently open in the system.
157 ¥·¥¹¥Æ¥à¤Ç¥ª¡¼¥×¥ó¤µ¤ì¤Æ¤¤¤ë¥Õ¥¡¥¤¥ë¤¬Â¿¤¹¤®¤ë¡£
160 .\"O Directory does not exist, or \fIname\fP is an empty string.
161 ¥Ç¥£¥ì¥¯¥È¥ê¤¬Â¸ºß¤·¤Ê¤¤¤«¡¢¤Þ¤¿¤Ï \fIname\fP ¤¬¶õʸ»úÎó¤Ç¤¢¤ë¡£
164 .\"O Insufficient memory to complete the operation.
165 Ì¿Îá¤ò¼Â¹Ô¤¹¤ë¤Î¤Ë½¼Ê¬¤Ê¥á¥â¥ê¤¬¤Ê¤¤¡£
168 .\"O \fIname\fP is not a directory.
169 \fIname\fP ¤Ï¥Ç¥£¥ì¥¯¥È¥ê¤Ç¤Ï¤Ê¤¤¡£
172 .\"O .BR fdopendir ()
173 .\"O is available in glibc since version 2.4.
175 ¤Ï glibc 2.4 °Ê¹ß¤ÇÍøÍѲÄǽ¤Ç¤¢¤ë¡£
176 .\"O .SH "CONFORMING TO"
179 .\"O is present on SVr4, 4.3BSD, and specified in POSIX.1-2001.
181 ¤Ï SVr4 ¤È 4.3BSD ¤Ë¸ºß¤·¡¢
182 POSIX.1-2001 ¤Çµ¬Äꤵ¤ì¤Æ¤¤¤ë¡£
183 .\"O .BR fdopendir ()
184 .\"O is specified in POSIX.1-2008.
186 ¤Ï POSIX.1-2008 ¤Çµ¬Äꤵ¤ì¤Æ¤¤¤ë¡£
189 .\"O The underlying file descriptor of the directory stream can be obtained using
191 ¥Ç¥£¥ì¥¯¥È¥ê¥¹¥È¥ê¡¼¥à¤ËÂбþ¤¹¤ë¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ï
193 ¤ò»ÈÍѤ·¤ÆÆÀ¤ë¤³¤È¤¬¤Ç¤¤ë¡£
197 .\"O function sets the close-on-exec flag for the file descriptor underlying the
200 .\"O .BR fdopendir ()
201 .\"O function leaves the setting of the close-on-exec
202 .\"O flag unchanged for the file descriptor,
207 ¤ÎÇظå¤Ë¤¢¤ë¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Î close-on-exec ¥Õ¥é¥°¤òÀßÄꤹ¤ë¡£
209 ´Ø¿ô¤Ï¡¢¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Î close-on-exec ¥Õ¥é¥°¤ÎÀßÄê¤òÊѹ¹¤·¤Ê¤¤¡£
210 .\"O POSIX.1-200x leaves it unspecified whether a successful call to
211 .\"O .BR fdopendir ()
212 .\"O will set the close-on-exec flag for the file descriptor,
215 ¤Î¸Æ¤Ó½Ð¤·¤¬À®¸ù¤·¤¿ºÝ¤Ë¡¢¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿
217 ¤Î close-on-exec ¤òÀßÄꤹ¤ë¤«¤É¤¦¤«¤Ï¡¢
218 POSIX.1-200x ¤Ç¤Ïµ¬Äꤵ¤ì¤Æ¤¤¤Ê¤¤¡£