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

OSS Library Calls (n - r) nftw(3)
DESCRIPTION
The nftw() function recursively searches the directory hierarchy that descends from the directory
specied by the path parameter. For each le in the hierarchy, nftw() calls the function pointed
to by the function parameter and passes four arguments.
The ag value passed to the function parameter identies the le type of the object specied for
the object parameter or provides other information that modies the operation of the nftw() func-
tion. The ag value can be one of the following:
FTW_D Species that the object is a directory.
FTW_DNR Species that the object is a directory that cannot be read.
FTW_DP Species that the object is a directory and that subdirectories have already been
traversed. This value is used only when the ags parameter includes the
FTW_DEPTH ag.
FTW_F Species that the object is a regular le.
FTW_NS Species that the object is a le for which the stat() function could not be exe-
cuted successfully.
FTW_SL Species that the object is a symbolic link. This value is used only when the
ags parameter includes the FTW_PHYS ag.
FTW_SLN Species that the object is a symbolic link that does not name an existing le.
This value is used only when the ags parameter does not include the
FTW_PHYS ag.
If ag is FTW_DNR, the les and subdirectories contained in that directory are not processed.
If ag is FTW_NS, the stat structure contents are meaningless. An example of a le that causes
FTW_NS to be passed to the function parameter is a le in a directory for which you have read
permission but not execute (search) permission. This condition also returns the value [EACCES]
in errno.
The nftw() function nishes processing a directory before processing any of its les or subdirec-
tories.
The nftw() function continues the search until either the directory hierarchy specied by the path
parameter is completely searched, an invocation of the function specied by the function parame-
ter returns a nonzero value, or an error is detected within nftw( ), such as an I/O error.
Because nftw( ) is recursive, it can terminate with a memory fault because of stack overow
when the function is called for very deep tree structures.
The nftw() function uses the malloc() function to allocate dynamic storage during its operation.
If nftw() is terminated prior to its completion, such as when the longjmp() function is executed
by the function specied by the function parameter, nftw( ) cannot free that storage. The storage
remains allocated.
The nftw() function traverses symbolic links encountered in the resolution of path, including the
nal component. Symbolic links encountered while traversing the directory tree rooted at path
are not traversed.
Use on Guardian Objects
All Guardian les (that is, les in /G) that are visible to the opendir( ) function can be traversed.
This includes temporary and structured les.
Safeguard subsystem security controls on Guardian objects do not affect the outcome of a call to
the nftw( ) function.
527187-007 Hewlett-Packard Company 55