1READDIR(2) Linux Programmer's Manual READDIR(2)
2
3
4
6 readdir - read directory entry
7
9 int readdir(unsigned int fd, struct old_linux_dirent *dirp,
10 unsigned int count);
11
13 This is not the function you are interested in. Look at readdir(3) for
14 the POSIX conforming C library interface. This page documents the bare
15 kernel system call interface, which is superseded by getdents(2).
16
17 readdir() reads one old_linux_dirent structure from the directory
18 referred to by the file descriptor fd into the buffer pointed to by
19 dirp. The argument count is ignored; at most one old_linux_dirent
20 structure is read.
21
22 The old_linux_dirent structure is declared as follows:
23
24 struct old_linux_dirent {
25 long d_ino; /* inode number */
26 off_t d_off; /* offset to this old_linux_dirent */
27 unsigned short d_reclen; /* length of this d_name */
28 char d_name[NAME_MAX+1]; /* filename (null-terminated) */
29 }
30
31 d_ino is an inode number. d_off is the distance from the start of the
32 directory to this old_linux_dirent. d_reclen is the size of d_name,
33 not counting the null terminator. d_name is a null-terminated file‐
34 name.
35
37 On success, 1 is returned. On end of directory, 0 is returned. On
38 error, -1 is returned, and errno is set appropriately.
39
41 EBADF Invalid file descriptor fd.
42
43 EFAULT Argument points outside the calling process's address space.
44
45 EINVAL Result buffer is too small.
46
47 ENOENT No such directory.
48
49 ENOTDIR
50 File descriptor does not refer to a directory.
51
53 This system call is Linux-specific.
54
56 Glibc does not provide a wrapper for this system call; call it using
57 syscall(2). You will need to define the old_linux_dirent structure
58 yourself.
59
61 getdents(2), readdir(3)
62
64 This page is part of release 3.22 of the Linux man-pages project. A
65 description of the project, and information about reporting bugs, can
66 be found at http://www.kernel.org/doc/man-pages/.
67
68
69
70Linux 2008-10-02 READDIR(2)