Blame man2/readdir.2

Packit 7cfc04
.\" Copyright (C) 1995 Andries Brouwer (aeb@cwi.nl)
Packit 7cfc04
.\"
Packit 7cfc04
.\" %%%LICENSE_START(VERBATIM)
Packit 7cfc04
.\" Permission is granted to make and distribute verbatim copies of this
Packit 7cfc04
.\" manual provided the copyright notice and this permission notice are
Packit 7cfc04
.\" preserved on all copies.
Packit 7cfc04
.\"
Packit 7cfc04
.\" Permission is granted to copy and distribute modified versions of this
Packit 7cfc04
.\" manual under the conditions for verbatim copying, provided that the
Packit 7cfc04
.\" entire resulting derived work is distributed under the terms of a
Packit 7cfc04
.\" permission notice identical to this one.
Packit 7cfc04
.\"
Packit 7cfc04
.\" Since the Linux kernel and libraries are constantly changing, this
Packit 7cfc04
.\" manual page may be incorrect or out-of-date.  The author(s) assume no
Packit 7cfc04
.\" responsibility for errors or omissions, or for damages resulting from
Packit 7cfc04
.\" the use of the information contained herein.  The author(s) may not
Packit 7cfc04
.\" have taken the same level of care in the production of this manual,
Packit 7cfc04
.\" which is licensed free of charge, as they might when working
Packit 7cfc04
.\" professionally.
Packit 7cfc04
.\"
Packit 7cfc04
.\" Formatted or processed versions of this manual, if unaccompanied by
Packit 7cfc04
.\" the source, must acknowledge the copyright and authors of this work.
Packit 7cfc04
.\" %%%LICENSE_END
Packit 7cfc04
.\"
Packit 7cfc04
.\" Written 11 June 1995 by Andries Brouwer <aeb@cwi.nl>
Packit 7cfc04
.\" Modified 22 July 1995 by Michael Chastain <mec@duracef.shout.net>:
Packit 7cfc04
.\"   In 1.3.X, returns only one entry each time; return value is different.
Packit 7cfc04
.\" Modified 2004-12-01, mtk, fixed headers listed in SYNOPSIS
Packit 7cfc04
.\"
Packit 7cfc04
.TH READDIR 2  2017-09-15 "Linux" "Linux Programmer's Manual"
Packit 7cfc04
.SH NAME
Packit 7cfc04
readdir \- read directory entry
Packit 7cfc04
.SH SYNOPSIS
Packit 7cfc04
.nf
Packit 7cfc04
.PP
Packit 7cfc04
.BI "int readdir(unsigned int " fd ", struct old_linux_dirent *" dirp ","
Packit 7cfc04
.BI "            unsigned int " count );
Packit 7cfc04
.fi
Packit 7cfc04
.PP
Packit 7cfc04
.IR Note :
Packit 7cfc04
There is no glibc wrapper for this system call; see NOTES.
Packit 7cfc04
.SH DESCRIPTION
Packit 7cfc04
This is not the function you are interested in.
Packit 7cfc04
Look at
Packit 7cfc04
.BR readdir (3)
Packit 7cfc04
for the POSIX conforming C library interface.
Packit 7cfc04
This page documents the bare kernel system call interface,
Packit 7cfc04
which is superseded by
Packit 7cfc04
.BR getdents (2).
Packit 7cfc04
.PP
Packit 7cfc04
.BR readdir ()
Packit 7cfc04
reads one
Packit 7cfc04
.I old_linux_dirent
Packit 7cfc04
structure from the directory
Packit 7cfc04
referred to by the file descriptor
Packit 7cfc04
.I fd
Packit 7cfc04
into the buffer pointed to by
Packit 7cfc04
.IR dirp .
Packit 7cfc04
The argument
Packit 7cfc04
.I count
Packit 7cfc04
is ignored; at most one
Packit 7cfc04
.I old_linux_dirent
Packit 7cfc04
structure is read.
Packit 7cfc04
.PP
Packit 7cfc04
The
Packit 7cfc04
.I old_linux_dirent
Packit 7cfc04
structure is declared as follows:
Packit 7cfc04
.PP
Packit 7cfc04
.in +4n
Packit 7cfc04
.EX
Packit 7cfc04
struct old_linux_dirent {
Packit 7cfc04
    long  d_ino;              /* inode number */
Packit 7cfc04
    off_t d_off;              /* offset to this \fIold_linux_dirent\fP */
Packit 7cfc04
    unsigned short d_reclen;  /* length of this \fId_name\fP */
Packit 7cfc04
    char  d_name[NAME_MAX+1]; /* filename (null-terminated) */
Packit 7cfc04
}
Packit 7cfc04
.EE
Packit 7cfc04
.in
Packit 7cfc04
.PP
Packit 7cfc04
.I d_ino
Packit 7cfc04
is an inode number.
Packit 7cfc04
.I d_off
Packit 7cfc04
is the distance from the start of the directory to this
Packit 7cfc04
.IR old_linux_dirent .
Packit 7cfc04
.I d_reclen
Packit 7cfc04
is the size of
Packit 7cfc04
.IR d_name ,
Packit 7cfc04
not counting the terminating null byte (\(aq\\0\(aq).
Packit 7cfc04
.I d_name
Packit 7cfc04
is a null-terminated filename.
Packit 7cfc04
.SH RETURN VALUE
Packit 7cfc04
On success, 1 is returned.
Packit 7cfc04
On end of directory, 0 is returned.
Packit 7cfc04
On error, \-1 is returned, and
Packit 7cfc04
.I errno
Packit 7cfc04
is set appropriately.
Packit 7cfc04
.SH ERRORS
Packit 7cfc04
.TP
Packit 7cfc04
.B EBADF
Packit 7cfc04
Invalid file descriptor
Packit 7cfc04
.IR fd .
Packit 7cfc04
.TP
Packit 7cfc04
.B EFAULT
Packit 7cfc04
Argument points outside the calling process's address space.
Packit 7cfc04
.TP
Packit 7cfc04
.B EINVAL
Packit 7cfc04
Result buffer is too small.
Packit 7cfc04
.TP
Packit 7cfc04
.B ENOENT
Packit 7cfc04
No such directory.
Packit 7cfc04
.TP
Packit 7cfc04
.B ENOTDIR
Packit 7cfc04
File descriptor does not refer to a directory.
Packit 7cfc04
.SH CONFORMING TO
Packit 7cfc04
This system call is Linux-specific.
Packit 7cfc04
.SH NOTES
Packit 7cfc04
Glibc does not provide a wrapper for this system call; call it using
Packit 7cfc04
.BR syscall (2).
Packit 7cfc04
You will need to define the
Packit 7cfc04
.I old_linux_dirent
Packit 7cfc04
structure yourself.
Packit 7cfc04
However, probably you should use
Packit 7cfc04
.BR readdir (3)
Packit 7cfc04
instead.
Packit 7cfc04
.PP
Packit 7cfc04
This system call does not exist on x86-64.
Packit 7cfc04
.SH SEE ALSO
Packit 7cfc04
.BR getdents (2),
Packit 7cfc04
.BR readdir (3)
Packit 7cfc04
.SH COLOPHON
Packit 7cfc04
This page is part of release 4.15 of the Linux
Packit 7cfc04
.I man-pages
Packit 7cfc04
project.
Packit 7cfc04
A description of the project,
Packit 7cfc04
information about reporting bugs,
Packit 7cfc04
and the latest version of this page,
Packit 7cfc04
can be found at
Packit 7cfc04
\%https://www.kernel.org/doc/man\-pages/.