1READDIR(2) Linux Programmer's Manual READDIR(2)
2
3
4
6 readdir - read directory entry
7
9 #include <sys/syscall.h> /* Definition of SYS_* constants */
10 #include <unistd.h>
11
12 int syscall(SYS_readdir, unsigned int fd,
13 struct old_linux_dirent *dirp, unsigned int count);
14
15 Note: There is no definition of struct old_linux_dirent; see NOTES.
16
18 This is not the function you are interested in. Look at readdir(3) for
19 the POSIX conforming C library interface. This page documents the bare
20 kernel system call interface, which is superseded by getdents(2).
21
22 readdir() reads one old_linux_dirent structure from the directory re‐
23 ferred to by the file descriptor fd into the buffer pointed to by dirp.
24 The argument count is ignored; at most one old_linux_dirent structure
25 is read.
26
27 The old_linux_dirent structure is declared (privately in Linux kernel
28 file fs/readdir.c) as follows:
29
30 struct old_linux_dirent {
31 unsigned long d_ino; /* inode number */
32 unsigned long d_offset; /* offset to this old_linux_dirent */
33 unsigned short d_namlen; /* length of this d_name */
34 char d_name[1]; /* filename (null-terminated) */
35 }
36
37 d_ino is an inode number. d_offset is the distance from the start of
38 the directory to this old_linux_dirent. d_reclen is the size of
39 d_name, not counting the terminating null byte ('\0'). d_name is a
40 null-terminated filename.
41
43 On success, 1 is returned. On end of directory, 0 is returned. On er‐
44 ror, -1 is returned, and errno is set to indicate the error.
45
47 EBADF Invalid file descriptor fd.
48
49 EFAULT Argument points outside the calling process's address space.
50
51 EINVAL Result buffer is too small.
52
53 ENOENT No such directory.
54
55 ENOTDIR
56 File descriptor does not refer to a directory.
57
59 This system call is Linux-specific.
60
62 You will need to define the old_linux_dirent structure yourself. How‐
63 ever, probably you should use readdir(3) instead.
64
65 This system call does not exist on x86-64.
66
68 getdents(2), readdir(3)
69
71 This page is part of release 5.13 of the Linux man-pages project. A
72 description of the project, information about reporting bugs, and the
73 latest version of this page, can be found at
74 https://www.kernel.org/doc/man-pages/.
75
76
77
78Linux 2021-03-22 READDIR(2)