]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/readdir.2
futex.2, netlink.3, stdin.3, wavelan.4, netlink.7: srcfix
[thirdparty/man-pages.git] / man2 / readdir.2
CommitLineData
fea681da
MK
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.
c13182ef 11.\"
fea681da
MK
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.
c13182ef 19.\"
fea681da
MK
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.
b4c0e1cb
MK
26.\" Modified 2004-12-01, mtk, fixed headers listed in SYNOPSIS
27.\"
45c99e3e 28.TH READDIR 2 2012-07-13 "Linux" "Linux Programmer's Manual"
fea681da
MK
29.SH NAME
30readdir \- read directory entry
31.SH SYNOPSIS
32.nf
fea681da 33.sp
b82f860a 34.BI "int readdir(unsigned int " fd ", struct old_linux_dirent *" dirp ","
93e4c37f 35.BI " unsigned int " count );
fea681da 36.fi
45c99e3e
MK
37
38.IR Note :
39There is no glibc wrapper for this system call; see NOTES.
fea681da
MK
40.SH DESCRIPTION
41This is not the function you are interested in.
42Look at
43.BR readdir (3)
44for the POSIX conforming C library interface.
45This page documents the bare kernel system call interface,
f8c4a808 46which is superseded by
fea681da
MK
47.BR getdents (2).
48.PP
e511ffb6 49.BR readdir ()
fea681da 50reads one
b82f860a 51.I old_linux_dirent
fea681da 52structure from the directory
602995ec 53referred to by the file descriptor
fea681da 54.I fd
602995ec 55into the buffer pointed to by
fea681da 56.IR dirp .
c4bb193f 57The argument
fea681da 58.I count
d3c8f8e2 59is ignored; at most one
b82f860a 60.I old_linux_dirent
d3c8f8e2 61structure is read.
fea681da
MK
62.PP
63The
b82f860a 64.I old_linux_dirent
fea681da
MK
65structure is declared as follows:
66.PP
088a639b 67.in +4n
fea681da 68.nf
b82f860a 69struct old_linux_dirent {
8c1e7c9c
MK
70 long d_ino; /* inode number */
71 off_t d_off; /* offset to this \fIold_linux_dirent\fP */
72 unsigned short d_reclen; /* length of this \fId_name\fP */
73 char d_name[NAME_MAX+1]; /* filename (null-terminated) */
fea681da
MK
74}
75.fi
a08ea57c 76.in
fea681da
MK
77.PP
78.I d_ino
79is an inode number.
80.I d_off
81is the distance from the start of the directory to this
b82f860a 82.IR old_linux_dirent .
fea681da
MK
83.I d_reclen
84is the size of
a5e0a0e4 85.IR d_name ,
cb8c0c9b 86not counting the terminating null byte.
fea681da 87.I d_name
2c5f1089 88is a null-terminated filename.
47297adb 89.SH RETURN VALUE
fea681da
MK
90On success, 1 is returned.
91On end of directory, 0 is returned.
92On error, \-1 is returned, and
93.I errno
94is set appropriately.
95.SH ERRORS
96.TP
97.B EBADF
98Invalid file descriptor
99.IR fd .
100.TP
101.B EFAULT
102Argument points outside the calling process's address space.
103.TP
104.B EINVAL
105Result buffer is too small.
106.TP
107.B ENOENT
108No such directory.
109.TP
110.B ENOTDIR
111File descriptor does not refer to a directory.
47297adb 112.SH CONFORMING TO
8382f16d 113This system call is Linux-specific.
c12fd10d
MK
114.SH NOTES
115Glibc does not provide a wrapper for this system call; call it using
116.BR syscall (2).
1dfd87ee
MK
117You will need to define the
118.I old_linux_dirent
119structure yourself.
45c99e3e
MK
120However, probably you should use
121.BR readdir (3)
122instead.
47297adb 123.SH SEE ALSO
fea681da
MK
124.BR getdents (2),
125.BR readdir (3)