Open System Services System Calls Reference Manual (G06.28+)

System Functions (r) readdir_r(2)
NAME
readdir_r - Reads a directory stream (reentrant)
LIBRARY
G-series native OSS processes: /G/system/sysnn/zsptsrl
H-series OSS processes: /G/system/zdllnnn/zsptdll
SYNOPSIS
[#include <sys/types.h>]
[#include <dirent.h>]
#include <spthread.h>
int readdir_r (
DIR *dirp,
struct dirent *ret,
struct dirent **result
);
PARAMETERS
dirp Points to the dirent structure of an open directory.
ret Points to the directory entry at the current position in the directory stream.
result Points to the struct dirent structure where the returned directory entry is stored.
DESCRIPTION
The readdir_r() function is the reentrant version of the readdir() function.
The type DIR, which is dened in the dirent.h header le, represents a directory stream. A
directory stream is an ordered sequence of all the directory entries in a particular directory.
(Directory streams are not implemented through le descriptors.) The structure pointed to by the
dirp parameter is established by a prior call to the opendir( ) function.
The readdir_r() function initializes the dirent structure referenced by the ret paremeter to
represent the directory entry at the current position in the directory stream referred to by the dirp
parameter, store a pointer to this structure at the location referenced by the result parameter, and
positions the directory stream at the next entry.
The storage pointed to by ret is large enough for a dirent with an array of char d_name
member containing at least NAME_MAX plus one elements.
Upon successful return, the pointer returned at *result has the same value as the value passed by
ret. Upon reaching the end of the directory stream, this pointer has the value NULL.
The readdir_r() function does not return directory entries containing empty names. It is
unspecied whether entries are returned for dot or dot-dot.
If a le is removed from or added to the directory after the most recent call to the opendir( ) or
rewinddir() function, whether a subsequent call to readdir_r() returns an entry for that le is
unspecied.
The readdir_r() function might buffer several directory entries per actual read operation; the
readdir_r() function marks for update the st_atime eld of the directory each time the directory
is actually read. Applications that need to check for error situations should set errno to 0 (zero)
before calling readdir().Iferrno is set to a nonzero value on return, an error occurred.
527186-005 Hewlett-Packard Company 67