Open System Services Library Calls Reference Manual (G06.28+, H06.05+)
opendir(3) OSS Library Calls Reference Manual
NAME
opendir - Opens a directory and creates a directory stream
LIBRARY
G-series native OSS processes: /G/system/sysnn/zossfsrl
H-series OSS processes: /G/system/zdllnnn/zossfdll
SYNOPSIS
#include <sys/types.h> /* optional except for POSIX.1 */
#include <dirent.h>
DIR *opendir(
const char *dir_name);
PARAMETERS
dir_name Names the directory. If the final component of dir_name names a symbolic link,
the link will be traversed and pathname resolution will continue.
DESCRIPTION
The opendir( ) function opens the directory designated by the dir_name parameter and associates
a directory stream with it. The directory stream is positioned at the first entry. The type DIR,
which is defined in the dirent.h header file, represents a directory stream, which is an ordered
sequence of all the directory entries in a particular directory. (Directory streams are not imple-
mented through file descriptors.)
The opendir( ) function returns a pointer to identify the directory stream in subsequent opera-
tions. The null pointer is returned when the directory named by the dir_name parameter cannot
be accessed or when not enough memory is available to hold the buffer stream.
The opendir( ) function does not update the st_atime field of the opened directory.
An open directory should always be closed with the closedir() function to ensure the freeing of
resources held by the stream.
When one of the set of exec, tdm_exec,ortdm_spawn functions is called, all open directory
streams are closed automatically. (For calls to tdm_spawn functions, only the directory streams
of the child process are closed.) The effect is the same as if the closedir() function had been
called for each open directory stream.
General Considerations for Directory Operations
Directory entries represent files. Files can be removed from a directory or added to a directory
asynchronously to the operation of the readdir() function.
If files are removed from a directory after the most recent call to the opendir() or rewinddir()
function but prior to the first call to the readdir() function, the readdir() function does not
return entries for these files. If files are added to a directory after the most recent call to the
opendir( ) or rewinddir( ) function but prior to the first call to the readdir() function, the read-
dir( ) function returns entries for these files.
The readdir() function retrieves a block of directory entries with each actual read operation and
stores them in a system buffer. The readdir() function marks for update the st_atime field of the
directory each time the directory is actually read.
The first call to the readdir() function after a call to the opendir() or rewinddir() function
retrieves a block of directory entries. The first two entries of the block are for . (dot) and ..(dot-
dot). Therefore, the first entry returned is for . (dot). Each subsequent call to readdir() fetches
another entry from the buffer until the buffer is empty, at which time another block of entries is
automatically retrieved.
A process that has an effective user ID or group ID that qualifies for membership in the Safe- |
guard SECURITY-OSS-ADMINISTRATOR group is granted read and search permissions on |
5−20 Hewlett-Packard Company 527187-007