OSDN Git Service

(split) LDP man-pages の original/ を v3.29 に更新。
[linuxjm/LDP_man-pages.git] / original / 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 .TH READDIR 2  2008-10-02 "Linux" "Linux Programmer's Manual"
29 .SH NAME
30 readdir \- read directory entry
31 .SH SYNOPSIS
32 .nf
33 .sp
34 .BI "int readdir(unsigned int " fd ", struct old_linux_dirent *" dirp ","
35 .BI "            unsigned int " count );
36 .fi
37 .SH DESCRIPTION
38 This is not the function you are interested in.
39 Look at
40 .BR readdir (3)
41 for the POSIX conforming C library interface.
42 This page documents the bare kernel system call interface,
43 which is superseded by
44 .BR getdents (2).
45 .PP
46 .BR readdir ()
47 reads one
48 .I old_linux_dirent
49 structure from the directory
50 referred to by the file descriptor
51 .I fd
52 into the buffer pointed to by
53 .IR dirp .
54 The argument
55 .I count
56 is ignored; at most one
57 .I old_linux_dirent
58 structure is read.
59 .PP
60 The
61 .I old_linux_dirent
62 structure is declared as follows:
63 .PP
64 .in +4n
65 .nf
66 struct old_linux_dirent {
67     long  d_ino;              /* inode number */
68     off_t d_off;              /* offset to this \fIold_linux_dirent\fP */
69     unsigned short d_reclen;  /* length of this \fId_name\fP */
70     char  d_name[NAME_MAX+1]; /* filename (null-terminated) */
71 }
72 .fi
73 .in
74 .PP
75 .I d_ino
76 is an inode number.
77 .I d_off
78 is the distance from the start of the directory to this
79 .IR old_linux_dirent .
80 .I d_reclen
81 is the size of
82 .IR d_name ,
83 not counting the terminating null byte.
84 .I d_name
85 is a null-terminated filename.
86 .SH "RETURN VALUE"
87 On success, 1 is returned.
88 On end of directory, 0 is returned.
89 On error, \-1 is returned, and
90 .I errno
91 is set appropriately.
92 .SH ERRORS
93 .TP
94 .B EBADF
95 Invalid file descriptor
96 .IR fd .
97 .TP
98 .B EFAULT
99 Argument points outside the calling process's address space.
100 .TP
101 .B EINVAL
102 Result buffer is too small.
103 .TP
104 .B ENOENT
105 No such directory.
106 .TP
107 .B ENOTDIR
108 File descriptor does not refer to a directory.
109 .SH "CONFORMING TO"
110 This system call is Linux-specific.
111 .SH NOTES
112 Glibc does not provide a wrapper for this system call; call it using
113 .BR syscall (2).
114 You will need to define the
115 .I old_linux_dirent
116 structure yourself.
117 .SH "SEE ALSO"
118 .BR getdents (2),
119 .BR readdir (3)