1readdir(2)                    System Calls Manual                   readdir(2)
2
3
4

NAME

6       readdir - read directory entry
7

LIBRARY

9       Standard C library (libc, -lc)
10

SYNOPSIS

12       #include <sys/syscall.h>      /* Definition of SYS_* constants */
13       #include <unistd.h>
14
15       int syscall(SYS_readdir, unsigned int fd,
16                   struct old_linux_dirent *dirp, unsigned int count);
17
18       Note: There is no definition of struct old_linux_dirent; see NOTES.
19

DESCRIPTION

21       This is not the function you are interested in.  Look at readdir(3) for
22       the POSIX conforming C library interface.  This page documents the bare
23       kernel system call interface, which is superseded by getdents(2).
24
25       readdir()  reads  one old_linux_dirent structure from the directory re‐
26       ferred to by the file descriptor fd into the buffer pointed to by dirp.
27       The  argument  count is ignored; at most one old_linux_dirent structure
28       is read.
29
30       The old_linux_dirent structure is declared (privately in  Linux  kernel
31       file fs/readdir.c) as follows:
32
33           struct old_linux_dirent {
34               unsigned long d_ino;     /* inode number */
35               unsigned long d_offset;  /* offset to this old_linux_dirent */
36               unsigned short d_namlen; /* length of this d_name */
37               char  d_name[1];         /* filename (null-terminated) */
38           }
39
40       d_ino  is  an inode number.  d_offset is the distance from the start of
41       the directory to  this  old_linux_dirent.   d_reclen  is  the  size  of
42       d_name,  not  counting  the  terminating null byte ('\0').  d_name is a
43       null-terminated filename.
44

RETURN VALUE

46       On success, 1 is returned.  On end of directory, 0 is returned.  On er‐
47       ror, -1 is returned, and errno is set to indicate the error.
48

ERRORS

50       EBADF  Invalid file descriptor fd.
51
52       EFAULT Argument points outside the calling process's address space.
53
54       EINVAL Result buffer is too small.
55
56       ENOENT No such directory.
57
58       ENOTDIR
59              File descriptor does not refer to a directory.
60

VERSIONS

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

STANDARDS

68       Linux.
69

SEE ALSO

71       getdents(2), readdir(3)
72
73
74
75Linux man-pages 6.05              2023-03-30                        readdir(2)
Impressum