Requirements Catalog of LSB Core 3.1

Requirements for the function 'ftw'
StandardIDDescription
SUSv3ftw.01 The ftw() function shall recursively descend the directory hierarchy rooted in path.
SUSv3ftw.02 For each object in the hierarchy, ftw() shall call the function pointed to by fn, passing it a pointer to a null-terminated character string containing the name of the object, a pointer to a stat structure containing information about the object, and an integer.
SUSv3ftw.03 Possible values of the integer, defined in the <ftw.h> header, are:
SUSv3ftw.03.01 FTW_D For a directory.
SUSv3ftw.03.02 FTW_DNR For a directory that cannot be read.
SUSv3ftw.03.03 FTW_F For a file.
SUSv3ftw.03.04 FTW_SL For a symbolic link (but see also FTW_NS below).
SUSv3ftw.03.05 FTW_NS
SUSv3ftw.03.05.01 For an object other than a symbolic link on which stat() could not successfully be executed.
SUSv3ftw.03.05.02 If the object is a symbolic link and stat() failed, it is unspecified whether ftw() passes FTW_SL or FTW_NS to the user-supplied function.
SUSv3ftw.04 If the integer is FTW_DNR, descendants of that directory shall not be processed.
SUSv3ftw.05 If the integer is FTW_NS, the stat structure contains undefined values.
SUSv3ftw.06 The ftw() function shall visit a directory before visiting any of its descendants.
SUSv3ftw.07 The ftw() function shall use at most one file descriptor for each level in the tree.
SUSv3app.ftw.01 The argument ndirs should be in the range [1, {OPEN_MAX}].
SUSv3ftw.08 The tree traversal shall continue until either the tree is exhausted, an invocation of fn returns a non-zero value, or some error, other than [EACCES], is detected within ftw().
SUSv3ftw.08.01 If the tree is exhausted, ftw() shall return 0.
SUSv3ftw.08.02 If the function pointed to by fn returns a non-zero value, ftw() shall stop its tree traversal and return whatever value was returned by the function pointed to by fn.
SUSv3ftw.08.03 If ftw() detects an error, it shall return -1 and set errno to indicate the error.
SUSv3ftw.08.04 If ftw() encounters an error other than [EACCES] (see FTW_DNR and FTW_NS above), it shall return -1 and set errno to indicate the error.
SUSv3ftw.09 The ndirs argument shall specify the maximum number of directory streams or file descriptors or both available for use by ftw() while traversing the tree.
SUSv3ftw.10 When ftw() returns it shall close any directory streams and file descriptors it uses not counting any opened by the application-supplied fn function.
SUSv3app.ftw.02 The results are unspecified if the application-supplied fn function does not preserve the current working directory.
SUSv3ftw.11 The external variable errno may contain any error value that is possible when a directory is opened or when one of the stat functions is executed on a directory or file.
SUSv3ftw.12 The ftw() function shall fail if:
SUSv3ftw.12.01 [EACCES] Search permission is denied for any component of path or read permission is denied for path.
SUSv3ftw.12.02 [ELOOP] A loop exists in symbolic links encountered during resolution of the path argument.
SUSv3ftw.12.03 [ENAMETOOLONG] The length of the path argument exceeds {PATH_MAX} or a pathname component is longer than {NAME_MAX}.
SUSv3ftw.12.04 [ENOENT] A component of path does not name an existing file or path is an empty string.
SUSv3ftw.12.05 [ENOTDIR] A component of path is not a directory.
SUSv3ftw.12.06 [EOVERFLOW] A field in the stat structure cannot be represented correctly in the current programming environment for one or more files found in the file hierarchy.
SUSv3ftw.13 The ftw() function may fail if:
SUSv3ftw.13.01 [EINVAL] The value of the ndirs argument is invalid.
SUSv3ftw.13.02 [ELOOP] More than {SYMLOOP_MAX} symbolic links were encountered during resolution of the path argument.
SUSv3ftw.13.03 [ENAMETOOLONG] Pathname resolution of a symbolic link produced an intermediate result whose length exceeds {PATH_MAX}.
SUSv3ftw.14 In addition, if the function pointed to by fn encounters system errors, errno may be set accordingly.
The text in the Description column of SUSv3 requirements is reproduced from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html