]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/readdir.2
Many pages: Use correct letter case in page titles (TH)
[thirdparty/man-pages.git] / man2 / readdir.2
CommitLineData
fea681da
MK
1.\" Copyright (C) 1995 Andries Brouwer (aeb@cwi.nl)
2.\"
5fbde956 3.\" SPDX-License-Identifier: Linux-man-pages-copyleft
fea681da
MK
4.\"
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.
b4c0e1cb
MK
8.\" Modified 2004-12-01, mtk, fixed headers listed in SYNOPSIS
9.\"
4c1c5274 10.TH readdir 2 (date) "Linux man-pages (unreleased)"
fea681da
MK
11.SH NAME
12readdir \- read directory entry
f737fbd8
AC
13.SH LIBRARY
14Standard C library
8fc3b2cf 15.RI ( libc ", " \-lc )
fea681da
MK
16.SH SYNOPSIS
17.nf
8f33ee07
AC
18.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */"
19.B #include <unistd.h>
68e4db0a 20.PP
8f33ee07
AC
21.BI "int syscall(SYS_readdir, unsigned int " fd ,
22.BI " struct old_linux_dirent *" dirp ", unsigned int " count );
fea681da 23.fi
dbfe9c70 24.PP
45c99e3e 25.IR Note :
8f33ee07
AC
26There is no definition of
27.BR "struct old_linux_dirent" ;
28see NOTES.
fea681da
MK
29.SH DESCRIPTION
30This is not the function you are interested in.
31Look at
32.BR readdir (3)
33for the POSIX conforming C library interface.
34This page documents the bare kernel system call interface,
f8c4a808 35which is superseded by
fea681da
MK
36.BR getdents (2).
37.PP
e511ffb6 38.BR readdir ()
fea681da 39reads one
b82f860a 40.I old_linux_dirent
fea681da 41structure from the directory
602995ec 42referred to by the file descriptor
fea681da 43.I fd
602995ec 44into the buffer pointed to by
fea681da 45.IR dirp .
c4bb193f 46The argument
fea681da 47.I count
d3c8f8e2 48is ignored; at most one
b82f860a 49.I old_linux_dirent
d3c8f8e2 50structure is read.
fea681da
MK
51.PP
52The
b82f860a 53.I old_linux_dirent
85722724
ES
54structure is declared (privately in Linux kernel file
55.BR fs/readdir.c )
56as follows:
fea681da 57.PP
088a639b 58.in +4n
b8302363 59.EX
b82f860a 60struct old_linux_dirent {
85722724
ES
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 */
d064d41a 64 char d_name[1]; /* filename (null\-terminated) */
fea681da 65}
b8302363 66.EE
a08ea57c 67.in
fea681da
MK
68.PP
69.I d_ino
70is an inode number.
85722724 71.I d_offset
fea681da 72is the distance from the start of the directory to this
b82f860a 73.IR old_linux_dirent .
fea681da
MK
74.I d_reclen
75is the size of
a5e0a0e4 76.IR d_name ,
d1a71985 77not counting the terminating null byte (\(aq\e0\(aq).
fea681da 78.I d_name
2c5f1089 79is a null-terminated filename.
47297adb 80.SH RETURN VALUE
fea681da
MK
81On success, 1 is returned.
82On end of directory, 0 is returned.
83On error, \-1 is returned, and
84.I errno
f6a4078b 85is set to indicate the error.
fea681da
MK
86.SH ERRORS
87.TP
88.B EBADF
89Invalid file descriptor
90.IR fd .
91.TP
92.B EFAULT
93Argument points outside the calling process's address space.
94.TP
95.B EINVAL
96Result buffer is too small.
97.TP
98.B ENOENT
99No such directory.
100.TP
101.B ENOTDIR
102File descriptor does not refer to a directory.
3113c7f3 103.SH STANDARDS
8382f16d 104This system call is Linux-specific.
c12fd10d 105.SH NOTES
1dfd87ee
MK
106You will need to define the
107.I old_linux_dirent
108structure yourself.
45c99e3e
MK
109However, probably you should use
110.BR readdir (3)
111instead.
efeece04 112.PP
d80cadc1 113This system call does not exist on x86-64.
47297adb 114.SH SEE ALSO
fea681da
MK
115.BR getdents (2),
116.BR readdir (3)