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
12 Note: There is no glibc wrapper for this system call; see NOTES.
13
15 This is not the function you are interested in. Look at readdir(3) for
16 the POSIX conforming C library interface. This page documents the bare
17 kernel system call interface, which is superseded by getdents(2).
18
19 readdir() reads one old_linux_dirent structure from the directory
20 referred to by the file descriptor fd into the buffer pointed to by
21 dirp. The argument count is ignored; at most one old_linux_dirent
22 structure is read.
23
24 The old_linux_dirent structure is declared as follows:
25
26 struct old_linux_dirent {
27 long d_ino; /* inode number */
28 off_t d_off; /* offset to this old_linux_dirent */
29 unsigned short d_reclen; /* length of this d_name */
30 char d_name[NAME_MAX+1]; /* filename (null-terminated) */
31 }
32
33 d_ino is an inode number. d_off is the distance from the start of the
34 directory to this old_linux_dirent. d_reclen is the size of d_name,
35 not counting the terminating null byte ('\0'). d_name is a null-termiā
36 nated filename.
37
39 On success, 1 is returned. On end of directory, 0 is returned. On
40 error, -1 is returned, and errno is set appropriately.
41
43 EBADF Invalid file descriptor fd.
44
45 EFAULT Argument points outside the calling process's address space.
46
47 EINVAL Result buffer is too small.
48
49 ENOENT No such directory.
50
51 ENOTDIR
52 File descriptor does not refer to a directory.
53
55 This system call is Linux-specific.
56
58 Glibc does not provide a wrapper for this system call; call it using
59 syscall(2). You will need to define the old_linux_dirent structure
60 yourself. However, probably you should use readdir(3) instead.
61
62 This system call does not exist on x86-64.
63
65 getdents(2), readdir(3)
66
68 This page is part of release 4.16 of the Linux man-pages project. A
69 description of the project, information about reporting bugs, and the
70 latest version of this page, can be found at
71 https://www.kernel.org/doc/man-pages/.
72
73
74
75Linux 2017-09-15 READDIR(2)