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