1 .\" Copyright (C) 1995 Andries Brouwer (aeb@cwi.nl)
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.
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.
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
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
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.
26 .\" Modified 2004-12-01, mtk, fixed headers listed in SYNOPSIS
28 .TH READDIR 2 1995-07-22 "Linux 1.3.6" "Linux Programmer's Manual"
30 readdir \- read directory entry
33 .B #include <linux/types.h>
34 .B #include <linux/dirent.h>
35 .B #include <linux/unistd.h>
38 .B _syscall3(int, readdir, unsigned int, fd, struct dirent *, dirp,
39 .B " unsigned int, count)"
40 /* Using \fBsyscall\fP(2) may be preferable; see \fBintro\fP(2) */
42 .BI "int readdir(unsigned int " fd ", struct dirent *" dirp ","
43 .BI " unsigned int " count );
46 This is not the function you are interested in.
49 for the POSIX conforming C library interface.
50 This page documents the bare kernel system call interface,
51 which can change, and which is superseded by
57 structure from the directory
60 into the memory area pointed to by
64 is ignored; at most one dirent structure is read.
68 structure is declared as follows:
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]; /* filename (null-terminated) */
85 is the distance from the start of the directory to this
90 not counting the null terminator.
92 is a null-terminated filename.
94 On success, 1 is returned.
95 On end of directory, 0 is returned.
96 On error, \-1 is returned, and
102 Invalid file descriptor
106 Argument points outside the calling process's address space.
109 Result buffer is too small.
115 File descriptor does not refer to a directory.
117 This system call is Linux specific.