Open System Services Library Calls Reference Manual (G06.28+, H06.05+)

OSS Library Calls (n - r) opendir(3)
any directory.
Use on Guardian Objects
A call to opendir() on /G, followed by calls to readdir(), returns all of the Guardian volumes on
the system.
The same sequence performed on /G/vol returns all of the subvolumes and temporary les on that
particular volume.
The same sequence performed on /G/vol/subvol returns all of the les on that particular subvo-
lume, including les that are inaccessible to the OSS interface such as Enscribe structured les
and SQL objects.
Guardian process names can be directories. However, a Guardian process cannot be opened
using opendir( ). Attempts to do so fail. If the named process is a subtype 30 process, errno is
set to [EPERM]. If the named process is not a subtype 30 process, errno is set to [ENOENT].
Use From the Guardian Environment
The opendir( ) function is one of a set of functions that have the following effects when the rst
of them is called from the Guardian environment:
Two Guardian le system le numbers (not necessarily the next two available) are allo-
cated for the root directory and the current working directory. These le numbers cannot
be closed by calling the Guardian FILE_CLOSE_ procedure.
The current working directory is assigned from the VOLUME attribute of the Guardian
environment =_DEFAULTS DEFINE.
The use of static memory by the process increases slightly.
These effects occur only when the rst of the set of functions is called. The effects are not cumu-
lative.
EXAMPLES
The following example shows how to open and search a directory for the entry name:
len = strlen(name);
dir_pointer = opendir(".");
for (dp = readdir(dir_pointer); dp != NULL;
dp = readdir(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 opendir() function returns a pointer to an object of type DIR.
Otherwise, null is returned and errno is set to indicate the error.
ERRORS
If any of the following conditions occurs, the opendir() function sets errno to the corresponding
value:
[EACCES] Search permission is denied for any component of the directory named by the
dir_name parameter, or read permission is denied for this name.
527187-007 Hewlett-Packard Company 521