]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/readdir.2
rtsig-max and rtsig-nr went away in 2.6.8
[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.
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.
b4c0e1cb
MK
26.\" Modified 2004-12-01, mtk, fixed headers listed in SYNOPSIS
27.\"
fea681da
MK
28.TH READDIR 2 1995-07-22 "Linux 1.3.6" "Linux Programmer's Manual"
29.SH NAME
30readdir \- read directory entry
31.SH SYNOPSIS
32.nf
b4c0e1cb
MK
33
34.B #include <linux/types.h>
fea681da
MK
35.B #include <linux/dirent.h>
36.B #include <linux/unistd.h>
b4c0e1cb 37.B #include <errno.h>
fea681da
MK
38.sp
39.B _syscall3(int, readdir, uint, fd, struct dirent *, dirp, uint, count);
40.sp
41.BI "int readdir(unsigned int " fd ", struct dirent *" dirp ", unsigned int " count );
42.fi
43.SH DESCRIPTION
44This is not the function you are interested in.
45Look at
46.BR readdir (3)
47for the POSIX conforming C library interface.
48This page documents the bare kernel system call interface,
49which can change, and which is superseded by
50.BR getdents (2).
51.PP
52.B readdir
53reads one
54.I dirent
55structure from the directory
56pointed at by
57.I fd
58into the memory area pointed to by
59.IR dirp .
60The parameter
61.I count
62is ignored; at most one dirent structure is read.
63.PP
64The
65.I dirent
66structure is declared as follows:
67.PP
68.RS
69.nf
70struct dirent
71{
72 long d_ino; /* inode number */
73 off_t d_off; /* offset to this \fIdirent\fP */
74 unsigned short d_reclen; /* length of this \fId_name\fP */
75 char d_name [NAME_MAX+1]; /* file name (null-terminated) */
76}
77.fi
78.RE
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
84.IR dirent .
85.I d_reclen
86is the size of
87.IR d_name,
88not counting the null terminator.
89.I d_name
90is a null-terminated file name.
91.PP
92.SH "RETURN VALUE"
93On success, 1 is returned.
94On end of directory, 0 is returned.
95On error, \-1 is returned, and
96.I errno
97is set appropriately.
98.SH ERRORS
99.TP
100.B EBADF
101Invalid file descriptor
102.IR fd .
103.TP
104.B EFAULT
105Argument points outside the calling process's address space.
106.TP
107.B EINVAL
108Result buffer is too small.
109.TP
110.B ENOENT
111No such directory.
112.TP
113.B ENOTDIR
114File descriptor does not refer to a directory.
115.SH "CONFORMING TO"
116This system call is Linux specific.
117.SH "SEE ALSO"
118.BR getdents (2),
119.BR readdir (3)