198 lines
4.4 KiB
HTML
198 lines
4.4 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of READDIR</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>READDIR</H1>
|
|
Section: Linux Programmer's Manual (2)<BR>Updated: 2019-03-06<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
readdir - read directory entry
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<PRE>
|
|
|
|
<B>int readdir(unsigned int </B><I>fd</I><B>, struct old_linux_dirent *</B><I>dirp</I><B>,</B>
|
|
<B> unsigned int </B><I>count</I><B>);</B>
|
|
</PRE>
|
|
|
|
<P>
|
|
|
|
<I>Note</I>:
|
|
|
|
There is no glibc wrapper for this system call; see NOTES.
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
This is not the function you are interested in.
|
|
Look at
|
|
<B><A HREF="/cgi-bin/man/man2html?3+readdir">readdir</A></B>(3)
|
|
|
|
for the POSIX conforming C library interface.
|
|
This page documents the bare kernel system call interface,
|
|
which is superseded by
|
|
<B><A HREF="/cgi-bin/man/man2html?2+getdents">getdents</A></B>(2).
|
|
|
|
<P>
|
|
|
|
<B>readdir</B>()
|
|
|
|
reads one
|
|
<I>old_linux_dirent</I>
|
|
|
|
structure from the directory
|
|
referred to by the file descriptor
|
|
<I>fd</I>
|
|
|
|
into the buffer pointed to by
|
|
<I>dirp</I>.
|
|
|
|
The argument
|
|
<I>count</I>
|
|
|
|
is ignored; at most one
|
|
<I>old_linux_dirent</I>
|
|
|
|
structure is read.
|
|
<P>
|
|
|
|
The
|
|
<I>old_linux_dirent</I>
|
|
|
|
structure is declared (privately in Linux kernel file
|
|
<B>fs/readdir.c</B>)
|
|
|
|
as follows:
|
|
<P>
|
|
|
|
|
|
|
|
struct old_linux_dirent {
|
|
<BR> unsigned long d_ino; /* inode number */
|
|
<BR> unsigned long d_offset; /* offset to this <I>old_linux_dirent</I> */
|
|
<BR> unsigned short d_namlen; /* length of this <I>d_name</I> */
|
|
<BR> char d_name[1]; /* filename (null-terminated) */
|
|
}
|
|
|
|
|
|
<P>
|
|
|
|
<I>d_ino</I>
|
|
|
|
is an inode number.
|
|
<I>d_offset</I>
|
|
|
|
is the distance from the start of the directory to this
|
|
<I>old_linux_dirent</I>.
|
|
|
|
<I>d_reclen</I>
|
|
|
|
is the size of
|
|
<I>d_name</I>,
|
|
|
|
not counting the terminating null byte ('\0').
|
|
<I>d_name</I>
|
|
|
|
is a null-terminated filename.
|
|
<A NAME="lbAE"> </A>
|
|
<H2>RETURN VALUE</H2>
|
|
|
|
On success, 1 is returned.
|
|
On end of directory, 0 is returned.
|
|
On error, -1 is returned, and
|
|
<I>errno</I>
|
|
|
|
is set appropriately.
|
|
<A NAME="lbAF"> </A>
|
|
<H2>ERRORS</H2>
|
|
|
|
<DL COMPACT>
|
|
<DT id="1"><B>EBADF</B>
|
|
|
|
<DD>
|
|
Invalid file descriptor
|
|
<I>fd</I>.
|
|
|
|
<DT id="2"><B>EFAULT</B>
|
|
|
|
<DD>
|
|
Argument points outside the calling process's address space.
|
|
<DT id="3"><B>EINVAL</B>
|
|
|
|
<DD>
|
|
Result buffer is too small.
|
|
<DT id="4"><B>ENOENT</B>
|
|
|
|
<DD>
|
|
No such directory.
|
|
<DT id="5"><B>ENOTDIR</B>
|
|
|
|
<DD>
|
|
File descriptor does not refer to a directory.
|
|
</DL>
|
|
<A NAME="lbAG"> </A>
|
|
<H2>CONFORMING TO</H2>
|
|
|
|
This system call is Linux-specific.
|
|
<A NAME="lbAH"> </A>
|
|
<H2>NOTES</H2>
|
|
|
|
Glibc does not provide a wrapper for this system call; call it using
|
|
<B><A HREF="/cgi-bin/man/man2html?2+syscall">syscall</A></B>(2).
|
|
|
|
You will need to define the
|
|
<I>old_linux_dirent</I>
|
|
|
|
structure yourself.
|
|
However, probably you should use
|
|
<B><A HREF="/cgi-bin/man/man2html?3+readdir">readdir</A></B>(3)
|
|
|
|
instead.
|
|
<P>
|
|
|
|
This system call does not exist on x86-64.
|
|
<A NAME="lbAI"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+getdents">getdents</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+readdir">readdir</A></B>(3)
|
|
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>COLOPHON</H2>
|
|
|
|
This page is part of release 5.05 of the Linux
|
|
<I>man-pages</I>
|
|
|
|
project.
|
|
A description of the project,
|
|
information about reporting bugs,
|
|
and the latest version of this page,
|
|
can be found at
|
|
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="6"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="7"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="8"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="9"><A HREF="#lbAE">RETURN VALUE</A><DD>
|
|
<DT id="10"><A HREF="#lbAF">ERRORS</A><DD>
|
|
<DT id="11"><A HREF="#lbAG">CONFORMING TO</A><DD>
|
|
<DT id="12"><A HREF="#lbAH">NOTES</A><DD>
|
|
<DT id="13"><A HREF="#lbAI">SEE ALSO</A><DD>
|
|
<DT id="14"><A HREF="#lbAJ">COLOPHON</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:34 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|