]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/getdents.2
After a note from Vasya Pupkin, I added <errno.h> to the SYNOPSIS
[thirdparty/man-pages.git] / man2 / getdents.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 .\" Derived from 'readdir.2'.
26 .\" Modified Tue Oct 22 08:11:14 EDT 1996 by Eric S. Raymond <esr@thyrsus.com>
27 .TH GETDENTS 2 1995-07-22 "Linux 1.3.6" "Linux Programmer's Manual"
28 .SH NAME
29 getdents \- get directory entries
30 .SH SYNOPSIS
31 .nf
32 .B #include <unistd.h>
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, getdents, uint, fd, struct dirent *, dirp, uint, count)
39 .sp
40 .BI "int getdents(unsigned int " fd ", struct dirent *" dirp ", unsigned int " count );
41 .fi
42 .SH DESCRIPTION
43 This is not the function you are interested in.
44 Look at
45 .BR readdir (3)
46 for the POSIX conforming C library interface.
47 This page documents the bare kernel system call interface.
48 .PP
49 The system call
50 .B getdents
51 reads several
52 .I dirent
53 structures from the directory
54 pointed at by
55 .I fd
56 into the memory area pointed to by
57 .IR dirp .
58 The parameter
59 .I count
60 is the size of the memory area.
61 .PP
62 The
63 .I dirent
64 structure is declared as follows:
65 .PP
66 .RS
67 .nf
68 struct dirent
69 {
70 long d_ino; /* inode number */
71 off_t d_off; /* offset to next \fIdirent\fP */
72 unsigned short d_reclen; /* length of this \fIdirent\fP */
73 char d_name [NAME_MAX+1]; /* file name (null-terminated) */
74 }
75 .fi
76 .RE
77 .PP
78 .I d_ino
79 is an inode number.
80 .I d_off
81 is the distance from the start of the directory to the start of the next
82 .IR dirent .
83 .I d_reclen
84 is the size of this entire
85 .IR dirent .
86 .I d_name
87 is a null-terminated file name.
88 .PP
89 This call supersedes
90 .BR readdir (2).
91 .SH "RETURN VALUE"
92 On success, the number of bytes read is returned.
93 On end of directory, 0 is returned.
94 On error, \-1 is returned, and
95 .I errno
96 is set appropriately.
97 .SH ERRORS
98 .TP
99 .B EBADF
100 Invalid file descriptor
101 .IR fd .
102 .TP
103 .B EFAULT
104 Argument points outside the calling process's address space.
105 .TP
106 .B EINVAL
107 Result buffer is too small.
108 .TP
109 .B ENOENT
110 No such directory.
111 .TP
112 .B ENOTDIR
113 File descriptor does not refer to a directory.
114 .SH "CONFORMING TO"
115 SVr4, SVID. SVr4 documents additional ENOLINK, EIO error conditions.
116 .SH "SEE ALSO"
117 .BR readdir (2),
118 .BR readdir (3)