1 .\" Copyright (C) 1995 Andries Brouwer (aeb@cwi.nl)
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.
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.
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
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
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 2008-06-22 "Linux" "Linux Programmer's Manual"
29 getdents \- get directory entries
32 .B #include <unistd.h>
33 .B #include <linux/types.h>
34 .B #include <linux/dirent.h>
35 .B #include <linux/unistd.h>
38 .BI "int getdents(unsigned int " fd ", struct dirent *" dirp ", unsigned int " count );
41 This is not the function you are interested in.
44 for the POSIX conforming C library interface.
45 This page documents the bare kernel system call interface.
51 structures from the directory
52 referred to by the open file descriptor
54 into the buffer pointed to by
58 is the size of the memory area.
62 structure is declared as follows:
67 unsigned long d_ino; /* Inode number */
68 unsigned long d_off; /* Offset to next \fIdirent\fP */
69 unsigned short d_reclen; /* Length of this \fIdirent\fP */
70 char d_name []; /* Filename (null-terminated) */
71 /* length is actually (d_reclen \- 2 \-
72 offsetof(struct linux_dirent, d_name) */
73 /* char pad; Zero padding byte */
74 /* char d_type; File type (only since Linux 2.6.4;
75 offset is (d_reclen \- 1)) */
84 is the distance from the start of the directory to the start of the next
87 is the size of this entire
90 is a null-terminated filename.
93 is a byte at the end of the structure that indicates the file type.
94 It returns one of the following values:
97 This is a block device.
100 This is a character device.
106 This is a named pipe (FIFO).
109 This is a symbolic link.
112 This is a regular file.
115 This is a Unix domain socket.
118 The file type is unknown.
120 On success, the number of bytes read is returned.
121 On end of directory, 0 is returned.
122 On error, \-1 is returned, and
124 is set appropriately.
128 Invalid file descriptor
132 Argument points outside the calling process's address space.
135 Result buffer is too small.
141 File descriptor does not refer to a directory.
144 .\" SVr4 documents additional ENOLINK, EIO error conditions.
146 Glibc does not provide a wrapper for this system call; call it using