OSDN Git Service

LDP: Update original to LDP v3.79
[linuxjm/LDP_man-pages.git] / original / man2 / readdir.2
1 .\" Copyright (C) 1995 Andries Brouwer (aeb@cwi.nl)
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\" Written 11 June 1995 by Andries Brouwer <aeb@cwi.nl>
26 .\" Modified 22 July 1995 by Michael Chastain <mec@duracef.shout.net>:
27 .\"   In 1.3.X, returns only one entry each time; return value is different.
28 .\" Modified 2004-12-01, mtk, fixed headers listed in SYNOPSIS
29 .\"
30 .TH READDIR 2  2013-06-21 "Linux" "Linux Programmer's Manual"
31 .SH NAME
32 readdir \- read directory entry
33 .SH SYNOPSIS
34 .nf
35 .sp
36 .BI "int readdir(unsigned int " fd ", struct old_linux_dirent *" dirp ","
37 .BI "            unsigned int " count );
38 .fi
39
40 .IR Note :
41 There is no glibc wrapper for this system call; see NOTES.
42 .SH DESCRIPTION
43 This is not the function you are interested in.
44 Look at
45 .BR readdir (3)
46 for the POSIX conforming C library interface.
47 This page documents the bare kernel system call interface,
48 which is superseded by
49 .BR getdents (2).
50 .PP
51 .BR readdir ()
52 reads one
53 .I old_linux_dirent
54 structure from the directory
55 referred to by the file descriptor
56 .I fd
57 into the buffer pointed to by
58 .IR dirp .
59 The argument
60 .I count
61 is ignored; at most one
62 .I old_linux_dirent
63 structure is read.
64 .PP
65 The
66 .I old_linux_dirent
67 structure is declared as follows:
68 .PP
69 .in +4n
70 .nf
71 struct old_linux_dirent {
72     long  d_ino;              /* inode number */
73     off_t d_off;              /* offset to this \fIold_linux_dirent\fP */
74     unsigned short d_reclen;  /* length of this \fId_name\fP */
75     char  d_name[NAME_MAX+1]; /* filename (null-terminated) */
76 }
77 .fi
78 .in
79 .PP
80 .I d_ino
81 is an inode number.
82 .I d_off
83 is the distance from the start of the directory to this
84 .IR old_linux_dirent .
85 .I d_reclen
86 is the size of
87 .IR d_name ,
88 not counting the terminating null byte (\(aq\\0\(aq).
89 .I d_name
90 is a null-terminated filename.
91 .SH RETURN VALUE
92 On success, 1 is returned.
93 On end of directory, 0 is returned.
94 On error, \-1 is returned, and
95 .I errno
96 is set appropriately.
97 .SH ERRORS
98 .TP
99 .B EBADF
100 Invalid file descriptor
101 .IR fd .
102 .TP
103 .B EFAULT
104 Argument points outside the calling process's address space.
105 .TP
106 .B EINVAL
107 Result buffer is too small.
108 .TP
109 .B ENOENT
110 No such directory.
111 .TP
112 .B ENOTDIR
113 File descriptor does not refer to a directory.
114 .SH CONFORMING TO
115 This system call is Linux-specific.
116 .SH NOTES
117 Glibc does not provide a wrapper for this system call; call it using
118 .BR syscall (2).
119 You will need to define the
120 .I old_linux_dirent
121 structure yourself.
122 However, probably you should use
123 .BR readdir (3)
124 instead.
125
126 This system call does not exist on x86-64.
127 .SH SEE ALSO
128 .BR getdents (2),
129 .BR readdir (3)
130 .SH COLOPHON
131 This page is part of release 3.79 of the Linux
132 .I man-pages
133 project.
134 A description of the project,
135 information about reporting bugs,
136 and the latest version of this page,
137 can be found at
138 \%http://www.kernel.org/doc/man\-pages/.