Print this page
1438 ftw(3C) should mention `quit' member of struct FTW and possible values


 133 
 134 
 135                   FTW_DNR
 136                              The object is a directory that cannot be read.
 137                              The user-defined function fn will not be called
 138                              for any of its descendants.
 139 
 140 
 141                   FTW_NS
 142                              The stat() function failed on the object because
 143                              of lack of appropriate permission. The stat
 144                              buffer passed to fn is undefined.  Failure of
 145                              stat() for any other reason is considered an
 146                              error and nftw() returns 1.
 147 
 148 
 149 
 150            o      The fourth argument is a pointer to an FTW structure that
 151                   contains the following members:
 152 

 153                     int   base;
 154                     int   level;
 155 














 156                   The base member is the offset of the object's filename in
 157                   the pathname passed as the first argument to fn(). The value
 158                   of level indicates the depth relative to the root of the
 159                   walk, where the root level is 0.
 160 
 161                   The results are unspecified if the application-supplied fn()
 162                   function does not preserve the current working directory.
 163 
 164 
 165        Both ftw() and nftw() use one file descriptor for each level in the
 166        tree. The depth argument limits the number of file descriptors used. If
 167        depth is zero or negative, the effect is the same as if it were 1. It
 168        must not be greater than the number of file descriptors currently
 169        available for use.  The ftw() function runs faster if depth is at least
 170        as large as the number of levels in the tree. Both ftw() and nftw() are
 171        able to descend to arbitrary depths in a file hierarchy and do not fail
 172        due to path length limitations unless either the length of the path
 173        name pointed to by the path argument exceeds {PATH_MAX} requirements,
 174        or for ftw(), the specified depth is less than 2, or for nftw(), the
 175        specified depth is less than 2 and FTW_CHDIR is not set. When ftw() and
 176        nftw() return, they close any file descriptors they have opened; they
 177        do not close any file descriptors that might have been opened by fn.

 178 
 179 RETURN VALUES
 180        If the tree is exhausted, ftw() and nftw() return 0. If the function
 181        pointed to by fn returns a non-zero value, ftw() and nftw() stop their
 182        tree traversal and return whatever value was returned by the function
 183        pointed to by fn. If ftw() and nftw() detect an error,  they return1
 184        and set errno to indicate the error.
 185 
 186 
 187        If ftw() and nftw() encounter an error other than EACCES (see FTW_DNR
 188        and FTW_NS above),  they return1 and set errno to indicate the error.
 189        The external variable errno can contain any error value that is
 190        possible when a directory is opened or when one of the stat functions
 191        is executed on a directory or file.
 192 
 193 ERRORS
 194        The ftw() and nftw() functions will fail if:
 195 
 196        ELOOP
 197                        A loop exists in symbolic links encountered during




 133 
 134 
 135                   FTW_DNR
 136                              The object is a directory that cannot be read.
 137                              The user-defined function fn will not be called
 138                              for any of its descendants.
 139 
 140 
 141                   FTW_NS
 142                              The stat() function failed on the object because
 143                              of lack of appropriate permission. The stat
 144                              buffer passed to fn is undefined.  Failure of
 145                              stat() for any other reason is considered an
 146                              error and nftw() returns 1.
 147 
 148 
 149 
 150            o      The fourth argument is a pointer to an FTW structure that
 151                   contains the following members:
 152 
 153                     int   quit;
 154                     int   base;
 155                     int   level;
 156 
 157                   The quit member has a default value of 0, but can be set to
 158                   the following values:
 159 
 160 
 161                   FTW_SKIP or FTW_PRUNE
 162                              This object and its descendants are pruned from
 163                              the search.
 164 
 165 
 166                   FTW_FOLLOW
 167                              If this object is a symbolic link, follow the
 168                              link to its physical counterpart.
 169 
 170 
 171                   The base member is the offset of the object's filename in
 172                   the pathname passed as the first argument to fn(). The value
 173                   of level indicates the depth relative to the root of the
 174                   walk, where the root level is 0.
 175 
 176                   The results are unspecified if the application-supplied fn()
 177                   function does not preserve the current working directory.
 178 
 179 
 180            Both ftw() and nftw() use one file descriptor for each level in the
 181            tree. The depth argument limits the number of file descriptors
 182            used. If depth is zero or negative, the effect is the same as if it
 183            were 1. It must not be greater than the number of file descriptors
 184            currently available for use.  The ftw() function runs faster if
 185            depth is at least as large as the number of levels in the tree.
 186            Both ftw() and nftw() are able to descend to arbitrary depths in a
 187            file hierarchy and do not fail due to path length limitations
 188            unless either the length of the path name pointed to by the path
 189            argument exceeds {PATH_MAX} requirements, or for ftw(), the
 190            specified depth is less than 2, or for nftw(), the specified depth
 191            is less than 2 and FTW_CHDIR is not set. When ftw() and nftw()
 192            return, they close any file descriptors they have opened; they do
 193            not close any file descriptors that might have been opened by fn.
 194 
 195 RETURN VALUES
 196        If the tree is exhausted, ftw() and nftw() return 0. If the function
 197        pointed to by fn returns a non-zero value, ftw() and nftw() stop their
 198        tree traversal and return whatever value was returned by the function
 199        pointed to by fn. If ftw() and nftw() detect an error,  they return1
 200        and set errno to indicate the error.
 201 
 202 
 203        If ftw() and nftw() encounter an error other than EACCES (see FTW_DNR
 204        and FTW_NS above),  they return1 and set errno to indicate the error.
 205        The external variable errno can contain any error value that is
 206        possible when a directory is opened or when one of the stat functions
 207        is executed on a directory or file.
 208 
 209 ERRORS
 210        The ftw() and nftw() functions will fail if:
 211 
 212        ELOOP
 213                        A loop exists in symbolic links encountered during