1getdents(2)                      System Calls                      getdents(2)
2
3
4

NAME

6       getdents  - read directory entries and put in a file system independent
7       format
8

SYNOPSIS

10       #include <dirent.h>
11
12       int getdents(int fildes, struct dirent *buf, size_t nbyte);
13
14

DESCRIPTION

16       The getdents() function attempts to read nbyte bytes from the directory
17       associated  with  the file descriptor fildes and to format them as file
18       system independent directory entries in the buffer pointed to  by  buf.
19       Since  the  file  system  independent directory entries are of variable
20       lengths, in most cases the actual number of bytes returned will be less
21       than nbyte. The file system independent directory entry is specified by
22       the dirent structure.  See dirent.h(3HEAD).
23
24
25       On devices capable of seeking, getdents() starts at a position  in  the
26       file given by the file pointer associated with fildes. Upon return from
27       getdents(), the file pointer is incremented to point to the next direc‐
28       tory entry.
29

RETURN VALUES

31       Upon successful completion, a non-negative integer is returned indicat‐
32       ing the number of bytes actually read. A return value  of  0  indicates
33       the  end  of  the directory has been reached. Otherwise, −1 is returned
34       and errno is set to indicate the error.
35

ERRORS

37       The getdents() function will fail if:
38
39       EBADF        The fildes argument is not a valid  file  descriptor  open
40                    for reading.
41
42
43       EFAULT       The buf argument points to an illegal address.
44
45
46       EINVAL       The  nbyte  argument is not large enough for one directory
47                    entry.
48
49
50       EIO          An I/O error occurred while accessing the file system.
51
52
53       ENOENT       The current file pointer for the directory is not  located
54                    at a valid entry.
55
56
57       ENOLINK      The  fildes  argument  points  to a remote machine and the
58                    link to that machine is no longer active.
59
60
61       ENOTDIR      The fildes argument is not a directory.
62
63
64       EOVERFLOW    The value of the dirent structure member  d_ino  or  d_off
65                    cannot be represented in an ino_t or  off_t.
66
67

USAGE

69       The  getdents()  function  was  developed  to implement the readdir(3C)
70       function and should not be used for other purposes.
71
72
73       The getdents() function has a transitional interface  for  64-bit  file
74       offsets.  See lf64(5).
75

SEE ALSO

77       readdir(3C), dirent.h(3HEAD), lf64(5)
78
79
80
81SunOS 5.11                        17 Jul 2001                      getdents(2)
Impressum