readdir_r - read a directory
This function is deprecated; use readdir(3) instead.
The readdir_r() function was invented as a reentrant version of readdir(3). It reads the next directory entry from the directory stream
dirp, and returns it in the caller-allocated buffer pointed to by
entry. For details of the
dirent structure, see readdir(3).
A pointer to the returned buffer is placed in
*result; if the end of the directory stream was encountered, then NULL is instead returned in
On systems where NAME_MAX is undefined, calling readdir_r() may be unsafe because the interface does not allow the caller to specify the length of the buffer used for the returned directory entry.
On some systems, readdir_r() can't read directory entries with very long names. When the glibc implementation encounters such a name, readdir_r() fails with the error ENAMETOOLONG
after the final directory entry has been read. On some other systems, readdir_r() may return a success status, but the returned
d_name field may not be null terminated or may be truncated.
In the current POSIX.1 specification (POSIX.1-2008), readdir(3) is not required to be thread-safe. However, in modern implementations (including the glibc implementation), concurrent calls to readdir(3) that specify different directory streams are thread-safe. Therefore, the use of readdir_r() is generally unnecessary in multithreaded programs. In cases where multiple threads must read from the same directory stream, using readdir(3) with external synchronization is still preferable to the use of readdir_r(), for the reasons given in the points above.
Invalid directory stream descriptor
A directory entry whose name was too long to be read was encountered.
This page is part of release 5.10 of the Linux
man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/.