/usr/ucb/cc[ flag ... ] file ... #include <sys/types.h> #include <sys/dir.h>
DIR *dirp;struct direct *readdir(dirp);
The readdir() function returns a pointer to a structure representing the directory entry at the current position in the directory stream to which dirp refers, and positions the directory stream at the next entry, except on read-only file systems. It returns a NULL pointer upon reaching the end of the directory stream, or upon detecting an invalid location in the directory. The readdir() function shall not return directory entries containing empty names. It is unspecified whether entries are returned for dot (.) or dot-dot (. .). The pointer returned by readdir() points to data that may be overwritten by another call to readdir() on the same directory stream. This data shall not be overwritten by another call to readdir() on a different directory stream. The readdir() function may buffer several directory entries per actual read operation. The readdir() function marks for update the st_atime field of the directory each time the directory is actually read.
The readdir() function returns NULL on failure and sets errno to indicate the error.
The readdir() function will fail if one or more of the following are true:
Mandatory file/record locking was set, O_NDELAY or O_NONBLOCK was set, and there was a blocking record lock.
Total amount of system memory available when reading using raw I/O is temporarily insufficient.
No data is waiting to be read on a file associated with a tty device and O_NONBLOCK was set.
No message is waiting to be read on a stream and O_NDELAY or O_NONBLOCK was set.
The file descriptor determined by the DIR stream is no longer valid. This results if the DIR stream has been closed.
Message waiting to be read on a stream is not a data message.
The read() was going to go to sleep and cause a deadlock to occur.
buf points to an illegal address.
A signal was caught during the read() or readv() function.
Attempted to read from a stream linked to a multiplexor.
A physical I/O error has occurred, or the process is in a background process group and is attempting to read from its controlling terminal,
and either the process is ignoring or blocking the
SIGTTIN signal or the process group of the process is orphaned.
The current file pointer for the directory is not located at a valid entry.
The system record lock table was full, so the read() or readv() could not go to sleep until the blocking record lock was removed.
fildes is on a remote machine and the link to that machine is no longer active.
The device associated with fildes is a block special or character special file and the value of the file pointer is out of range.
The value of the direct structure member d_ino cannot be represented in an ino_t.
The readdir() function has a transitional interface for 64-bit file offsets. See lf64(5).
Use of these interfaces should be restricted to only applications written on BSD platforms. Use of these interfaces with any of the system libraries or in multi-thread applications is unsupported.