]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/readdir.2
Wrapped long lines, wrapped at sentence boundaries; stripped trailing
[thirdparty/man-pages.git] / man2 / readdir.2
1 .\" Copyright (C) 1995 Andries Brouwer (aeb@cwi.nl)
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" Written 11 June 1995 by Andries Brouwer <aeb@cwi.nl>
24 .\" Modified 22 July 1995 by Michael Chastain <mec@duracef.shout.net>:
25 .\" In 1.3.X, returns only one entry each time; return value is different.
26 .\" Modified 2004-12-01, mtk, fixed headers listed in SYNOPSIS
27 .\"
28 .TH READDIR 2 1995-07-22 "Linux 1.3.6" "Linux Programmer's Manual"
29 .SH NAME
30 readdir \- read directory entry
31 .SH SYNOPSIS
32 .nf
33 .B #include <linux/types.h>
34 .B #include <linux/dirent.h>
35 .B #include <linux/unistd.h>
36 .B #include <errno.h>
37 .sp
38 .B _syscall3(int, readdir, unsigned int, fd, struct dirent *, dirp,
39 .B " unsigned int, count)"
40 /* Using \fBsyscall\fP(2) may be preferable; see \fBintro\fP(2) */
41 .sp
42 .BI "int readdir(unsigned int " fd ", struct dirent *" dirp ","
43 .BI " unsigned int " count );
44 .fi
45 .SH DESCRIPTION
46 This is not the function you are interested in.
47 Look at
48 .BR readdir (3)
49 for the POSIX conforming C library interface.
50 This page documents the bare kernel system call interface,
51 which can change, and which is superseded by
52 .BR getdents (2).
53 .PP
54 .BR readdir ()
55 reads one
56 .I dirent
57 structure from the directory
58 pointed at by
59 .I fd
60 into the memory area pointed to by
61 .IR dirp .
62 The parameter
63 .I count
64 is ignored; at most one dirent structure is read.
65 .PP
66 The
67 .I dirent
68 structure is declared as follows:
69 .PP
70 .RS
71 .nf
72 struct dirent
73 {
74 long d_ino; /* inode number */
75 off_t d_off; /* offset to this \fIdirent\fP */
76 unsigned short d_reclen; /* length of this \fId_name\fP */
77 char d_name [NAME_MAX+1]; /* filename (null-terminated) */
78 }
79 .fi
80 .RE
81 .PP
82 .I d_ino
83 is an inode number.
84 .I d_off
85 is the distance from the start of the directory to this
86 .IR dirent .
87 .I d_reclen
88 is the size of
89 .IR d_name ,
90 not counting the null terminator.
91 .I d_name
92 is a null-terminated filename.
93 .SH "RETURN VALUE"
94 On success, 1 is returned.
95 On end of directory, 0 is returned.
96 On error, \-1 is returned, and
97 .I errno
98 is set appropriately.
99 .SH ERRORS
100 .TP
101 .B EBADF
102 Invalid file descriptor
103 .IR fd .
104 .TP
105 .B EFAULT
106 Argument points outside the calling process's address space.
107 .TP
108 .B EINVAL
109 Result buffer is too small.
110 .TP
111 .B ENOENT
112 No such directory.
113 .TP
114 .B ENOTDIR
115 File descriptor does not refer to a directory.
116 .SH "CONFORMING TO"
117 This system call is Linux specific.
118 .SH "SEE ALSO"
119 .BR getdents (2),
120 .BR readdir (3)