1 .\" Copyright (C) 1995 Andries Brouwer (aeb@cwi.nl)
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\" Written 11 June 1995 by Andries Brouwer <aeb@cwi.nl>
6 .\" Modified 22 July 1995 by Michael Chastain <mec@duracef.shout.net>:
7 .\" In 1.3.X, returns only one entry each time; return value is different.
8 .\" Modified 2004-12-01, mtk, fixed headers listed in SYNOPSIS
10 .TH READDIR 2 2021-03-22 "Linux" "Linux Programmer's Manual"
12 readdir \- read directory entry
15 .RI ( libc ", " \-lc )
18 .BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */"
19 .B #include <unistd.h>
21 .BI "int syscall(SYS_readdir, unsigned int " fd ,
22 .BI " struct old_linux_dirent *" dirp ", unsigned int " count );
26 There is no definition of
27 .BR "struct old_linux_dirent" ;
30 This is not the function you are interested in.
33 for the POSIX conforming C library interface.
34 This page documents the bare kernel system call interface,
35 which is superseded by
41 structure from the directory
42 referred to by the file descriptor
44 into the buffer pointed to by
48 is ignored; at most one
54 structure is declared (privately in Linux kernel file
60 struct old_linux_dirent {
61 unsigned long d_ino; /* inode number */
62 unsigned long d_offset; /* offset to this \fIold_linux_dirent\fP */
63 unsigned short d_namlen; /* length of this \fId_name\fP */
64 char d_name[1]; /* filename (null\-terminated) */
72 is the distance from the start of the directory to this
73 .IR old_linux_dirent .
77 not counting the terminating null byte (\(aq\e0\(aq).
79 is a null-terminated filename.
81 On success, 1 is returned.
82 On end of directory, 0 is returned.
83 On error, \-1 is returned, and
85 is set to indicate the error.
89 Invalid file descriptor
93 Argument points outside the calling process's address space.
96 Result buffer is too small.
102 File descriptor does not refer to a directory.
104 This system call is Linux-specific.
106 You will need to define the
109 However, probably you should use
113 This system call does not exist on x86-64.