Open System Services Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)

OSS Library Calls (n - r) readdir64(3)
EXAMPLES
The following example shows how to search a directory for the entry name:
len = strlen(name);
dir_pointer = opendir(".");
for (dp = readdir64(dir_pointer); dp != NULL;
dp = readdir64(dir_pointer))
if (strlen(dp->d_name) == len && !strcmp(dp->d_name, name)) {
closedir(dir_pointer);
return FOUND;
}
closedir(dir_pointer);
return NOT_FOUND;
RETURN VALUES
Upon successful completion, the readdir64( ) function returns a pointer to an object of type
struct dirent64. When an error is encountered, a null pointer is returned and errno is set to indi-
cate the error. When the end of the directory is encountered, a null pointer is returned and errno
is not changed.
For Guardian disk volumes and subvolumes (directories with OSS pathnames of the form /G/vol
and /G/vol/subvol), values returned by the telldir( ) function are kept in a table. When the table
containing these values overflows, the previous telldir( ) function value becomes invalid.
When table overflow occurs but the telldir( ) function has not returned a value, a subsequent call
to the readdir64() function does not set errno to [EINVAL].
ERRORS
If any of the following conditions occurs, the readdir64( ) function sets errno to the correspond-
ing value:
[EBADF] The dir_pointer parameter does not point to a valid directory structure open for
reading. This error is returned instead of [EFAULT] if the process has copied
and altered the structure pointed to by the dir_pointer parameter after the system
has freed the buffer that contains the structure.
[EFAULT] The dir_pointer parameter does not point to a valid directory structure open for
reading.
[EINVAL] Table overflow occurred after the last valid telldir( ) function call for a Guardian
disk volume or subvolume. Only the last 128 values returned by the telldir( )
function can be saved in the table.
[EIO] An I/O error occurred during a read from the directory.
[ENETDOWN]
The dir_pointer parameter specifies a directory on a remote HP NonStop server
node, but communication with the remote node has been lost.
[ENOENT] An invalid position value was used in the previous call to the seekdir( ) function.
[ENOMEM] The system has insufcient resources to complete the request.
[ENOROOT] The root fileset (fileset 0) is not in the STARTED state.
527187-017 Hewlett-Packard Company 5143