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