1GETDENTS(2)                Linux Programmer's Manual               GETDENTS(2)
2
3
4

NAME

6       getdents - get directory entries
7

SYNOPSIS

9       #include <unistd.h>
10       #include <linux/types.h>
11       #include <linux/dirent.h>
12       #include <linux/unistd.h>
13       #include <errno.h>
14
15       _syscall3(int, getdents, uint, fd, struct dirent *, dirp, uint, count)
16               /* Using syscall(2) may be preferable; see intro(2) */
17
18       int getdents(unsigned int fd, struct dirent *dirp, unsigned int count);
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.
24
25       The  system  call  getdents()  reads several dirent structures from the
26       directory pointed at by fd into the memory area  pointed  to  by  dirp.
27       The parameter count is the size of the memory area.
28
29       The dirent structure is declared as follows:
30
31              struct dirent
32              {
33                  long d_ino;                 /* inode number */
34                  off_t d_off;                /* offset to next dirent */
35                  unsigned short d_reclen;    /* length of this dirent */
36                  char d_name [NAME_MAX+1];   /* filename (null-terminated) */
37              }
38
39       d_ino  is an inode number.  d_off is the distance from the start of the
40       directory to the start of the next dirent.  d_reclen  is  the  size  of
41       this entire dirent.  d_name is a null-terminated filename.
42
43       This call supersedes readdir(2).
44

RETURN VALUE

46       On success, the number of bytes read is returned.  On end of directory,
47       0 is returned.  On error, -1 is returned, and errno  is  set  appropriā€
48       ately.
49

ERRORS

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

CONFORMING TO

63       SVr4.
64

SEE ALSO

66       readdir(2), readdir(3)
67
68
69
70Linux 1.3.6                       1995-07-22                       GETDENTS(2)
Impressum