1 .\" Copyright (C) 1995 Andries Brouwer (aeb@cwi.nl)
3 .\" %%%LICENSE_START(VERBATIM)
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.
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.
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
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
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.
28 .\" Modified 2004-12-01, mtk, fixed headers listed in SYNOPSIS
30 .TH READDIR 2 2021-03-22 "Linux" "Linux Programmer's Manual"
32 readdir \- read directory entry
35 .BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */"
36 .B #include <unistd.h>
38 .BI "int syscall(SYS_readdir, unsigned int " fd ,
39 .BI " struct old_linux_dirent *" dirp ", unsigned int " count );
43 There is no definition of
44 .BR "struct old_linux_dirent" ;
47 This is not the function you are interested in.
50 for the POSIX conforming C library interface.
51 This page documents the bare kernel system call interface,
52 which is superseded by
58 structure from the directory
59 referred to by the file descriptor
61 into the buffer pointed to by
65 is ignored; at most one
71 structure is declared (privately in Linux kernel file
77 struct old_linux_dirent {
78 unsigned long d_ino; /* inode number */
79 unsigned long d_offset; /* offset to this \fIold_linux_dirent\fP */
80 unsigned short d_namlen; /* length of this \fId_name\fP */
81 char d_name[1]; /* filename (null\-terminated) */
89 is the distance from the start of the directory to this
90 .IR old_linux_dirent .
94 not counting the terminating null byte (\(aq\e0\(aq).
96 is a null-terminated filename.
98 On success, 1 is returned.
99 On end of directory, 0 is returned.
100 On error, \-1 is returned, and
102 is set to indicate the error.
106 Invalid file descriptor
110 Argument points outside the calling process's address space.
113 Result buffer is too small.
119 File descriptor does not refer to a directory.
121 This system call is Linux-specific.
123 You will need to define the
126 However, probably you should use
130 This system call does not exist on x86-64.