Requirements Catalog of LSB Core 3.1

Requirements for the function 'nftw'
StandardIDDescription
SUSv3nftw.01 The nftw() function shall recursively descend the directory hierarchy rooted in path.
SUSv3nftw.02 The nftw() function has a similar effect to ftw() except that it takes an additional argument flags, which is a bitwise-inclusive OR of zero or more of the following flags:
SUSv3nftw.02.01 FTW_CHDIR
SUSv3nftw.02.01.01 If set, nftw() shall change the current working directory to each directory as it reports files in that directory.
SUSv3nftw.02.01.02 If clear, nftw() shall not change the current working directory.
SUSv3nftw.02.02 FTW_DEPTH
SUSv3nftw.02.02.01 If set, nftw() shall report all files in a directory before reporting the directory itself.
SUSv3nftw.02.02.02 If clear, nftw() shall report any directory before reporting the files in that directory.
SUSv3nftw.02.03 FTW_MOUNT
SUSv3nftw.02.03.01 If set, nftw() shall only report files in the same file system as path.
SUSv3nftw.02.03.02 If clear, nftw() shall report all files encountered during the walk.
SUSv3nftw.02.04 FTW_PHYS If set, nftw() shall perform a physical walk and shall not follow symbolic links.
SUSv3nftw.02.05 If FTW_PHYS is clear and FTW_DEPTH is set, nftw() shall follow links instead of reporting them, but shall not report any directory that would be a descendant of itself.
SUSv3nftw.02.06 If FTW_PHYS is clear and FTW_DEPTH is clear, nftw() shall follow links instead of reporting them, but shall not report the contents of any directory that would be a descendant of itself.
SUSv3nftw.03 At each file it encounters, nftw() shall call the user-supplied function fn with four arguments:
SUSv3nftw.03.01 The first argument is the pathname of the object.
SUSv3nftw.03.02 The second argument is a pointer to the stat buffer containing information on the object.
SUSv3nftw.03.03 The third argument is an integer giving additional information. Its value is one of the following:
SUSv3nftw.03.03.01 FTW_F The object is a file.
SUSv3nftw.03.03.02 FTW_D The object is a directory.
SUSv3nftw.03.03.03 FTW_DP The object is a directory and subdirectories have been visited. (This condition shall only occur if the FTW_DEPTH flag is included in flags.)
SUSv3nftw.03.03.04 FTW_SL The object is a symbolic link. (This condition shall only occur if the FTW_PHYS flag is included in flags.)
SUSv3nftw.03.03.05 FTW_SLN The object is a symbolic link that does not name an existing file. (This condition shall only occur if the FTW_PHYS flag is not included in flags.)
SUSv3nftw.03.03.06 FTW_DNR
SUSv3nftw.03.03.06.01 The object is a directory that cannot be read.
SUSv3nftw.03.03.06.02 The fn function shall not be called for any of its descendants.
SUSv3nftw.03.03.07 FTW_NS The stat() function failed on the object because of lack of appropriate permission. The stat buffer passed to fn is undefined. Failure of stat() for any other reason is considered an error and nftw() shall return -1.
SUSv3nftw.03.04 The fourth argument is a pointer to an FTW structure. The value of base is the offset of the object's filename in the pathname passed as the first argument to fn. The value of level indicates depth relative to the root of the walk, where the root level is 0.
SUSv3app.nftw.01 The results are unspecified if the application-supplied fn function does not preserve the current working directory.
SUSv3nftw.04 The argument fd_limit sets the maximum number of file descriptors that shall be used by nftw() while traversing the file tree.
SUSv3nftw.05 At most one file descriptor shall be used for each directory level.
SUSv3nftw.06 The nftw() function shall continue until the first of the following conditions occurs:
SUSv3nftw.06.01 An invocation of fn shall return a non-zero value, in which case nftw() shall return that value.
SUSv3nftw.06.02 The nftw() function detects an error other than [EACCES] (see FTW_DNR and FTW_NS above), in which case nftw() shall return -1 and set errno to indicate the error.
SUSv3nftw.06.03 The tree is exhausted, in which case nftw() shall return 0.
SUSv3nftw.07 The nftw() function shall fail if:
SUSv3nftw.07.01 [EACCES] Search permission is denied for any component of path or read permission is denied for path, or fn returns -1 and does not reset errno.
SUSv3nftw.07.02 [ELOOP] A loop exists in symbolic links encountered during resolution of the path argument.
SUSv3nftw.07.03 [ENAMETOOLONG] The length of the path argument exceeds {PATH_MAX} or a pathname component is longer than {NAME_MAX}.
SUSv3nftw.07.04 [ENOENT] A component of path does not name an existing file or path is an empty string.
SUSv3nftw.07.05 [ENOTDIR] A component of path is not a directory.
SUSv3nftw.07.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.
SUSv3nftw.08 The nftw() function may fail if:
SUSv3nftw.08.01 [ELOOP] More than {SYMLOOP_MAX} symbolic links were encountered during resolution of the path argument.
SUSv3nftw.08.02 [EMFILE] {OPEN_MAX} file descriptors are currently open in the calling process.
SUSv3nftw.08.03 [ENAMETOOLONG] Pathname resolution of a symbolic link produced an intermediate result whose length exceeds {PATH_MAX}.
SUSv3nftw.08.04 [ENFILE] Too many files are currently open in the system.
SUSv3nftw.09 In addition, errno may be set if the function pointed to by fn causes errno to be set.
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