1readdir(3UCB)      SunOS/BSD Compatibility Library Functions     readdir(3UCB)
2
3
4

NAME

6       readdir - read a directory entry
7

SYNOPSIS

9       /usr/ucb/cc [ flag ... ] file ...
10       #include <sys/types.h>
11       #include <sys/dir.h>
12
13       struct direct *readdir(dirp)
14       DIR *dirp;
15
16

DESCRIPTION

18       The  readdir()  function  returns a pointer to a structure representing
19       the directory entry at the current position in the directory stream  to
20       which  dirp  refers,  and  positions  the  directory stream at the next
21       entry, except on read-only file systems. It returns a NULL pointer upon
22       reaching  the end of the directory stream, or upon detecting an invalid
23       location in the directory.  The readdir()  function  shall  not  return
24       directory  entries  containing  empty names.  It is unspecified whether
25       entries are returned  for dot (.) or dot-dot (..). The pointer returned
26       by  readdir() points to data that may be overwritten by another call to
27       readdir() on the same directory stream. This data shall not  be   over‐
28       written  by another call to  readdir() on a different directory stream.
29       The readdir() function may buffer several directory entries per  actual
30       read  operation.  The  readdir() function marks for update the st_atime
31       field of the directory each time the directory is actually read.
32

RETURN VALUES

34       The readdir() function returns NULL on failure and sets errno to  indi‐
35       cate the error.
36

ERRORS

38       The  readdir()  function  will fail if one or more of the following are
39       true:
40
41       EAGAIN       Mandatory file/record locking was set, O_NDELAY or  O_NON‐
42                    BLOCK was set, and there was a blocking record lock.
43
44
45       EAGAIN       Total amount of system memory available when reading using
46                    raw I/O is temporarily insufficient.
47
48
49       EAGAIN       No data is waiting to be read on a file associated with  a
50                    tty device and  O_NONBLOCK was set.
51
52
53       EAGAIN       No message is waiting to be read on a stream and  O_NDELAY
54                    or  O_NONBLOCK was set.
55
56
57       EBADF        The file descriptor determined by the  DIR  stream  is  no
58                    longer  valid.  This  results  if  the DIR stream has been
59                    closed.
60
61
62       EBADMSG      Message waiting to be read on a stream is not a data  mes‐
63                    sage.
64
65
66       EDEADLK      The  read()  was going to go to sleep and cause a deadlock
67                    to occur.
68
69
70       EFAULT       buf points to an illegal address.
71
72
73       EINTR        A signal was caught during the read() or readv() function.
74
75
76       EINVAL       Attempted to read from a stream linked to a multiplexor.
77
78
79       EIO          A physical I/O error has occurred, or the process is in  a
80                    background  process  group  and is attempting to read from
81                    its controlling terminal, and either the process is ignor‐
82                    ing or blocking the SIGTTIN signal or the process group of
83                    the process is orphaned.
84
85
86       ENOENT       The current file pointer for the directory is not  located
87                    at a valid entry.
88
89
90       ENOLCK       The  system  record  lock table was full, so the read() or
91                    readv() could not go to sleep until  the  blocking  record
92                    lock was removed.
93
94
95       ENOLINK      fildes is on a remote machine and the link to that machine
96                    is no longer active.
97
98
99       ENXIO        The device associated with  fildes is a block  special  or
100                    character  special  file and the value of the file pointer
101                    is out of range.
102
103
104       EOVERFLOW    The value of the direct structure member d_ino  cannot  be
105                    represented in an ino_t.
106
107

USAGE

109       The  readdir()  function  has  a transitional interface for 64-bit file
110       offsets. See lf64(5).
111

SEE ALSO

113       getdents(2), readdir(3C), scandir(3UCB), lf64(5)
114

NOTES

116       Use of these interfaces should be restricted to only applications writ‐
117       ten  on  BSD platforms.  Use of these interfaces with any of the system
118       libraries or in multi-thread applications is unsupported.
119
120
121
122SunOS 5.11                        30 Oct 2007                    readdir(3UCB)
Impressum