errno = cache->error;
} else if (bfs_stat(ftwbuf->at_fd, ftwbuf->at_path, flags, &cache->storage) == 0) {
cache->buf = &cache->storage;
+#ifdef S_IFWHT
+ } else if (errno == ENOENT && ftwbuf->type == BFS_WHT) {
+ // This matches the behavior of FTS_WHITEOUT on BSD
+ memset(&cache->storage, 0, sizeof(cache->storage));
+ cache->storage.mode = S_IFWHT;
+ cache->buf = &cache->storage;
+#endif
} else {
cache->error = errno;
}
enum bftw_strategy strategy;
/** The mount table. */
const struct bfs_mtab *mtab;
+ /** bfs_opendir() flags. */
+ enum bfs_dir_flags dir_flags;
/** The appropriate errno value, if any. */
int error;
state->flags = args->flags;
state->strategy = args->strategy;
state->mtab = args->mtab;
+ state->dir_flags = 0;
state->error = 0;
if (args->nopenfd < 2) {
state->flags |= BFTW_BUFFER;
}
+ if (state->flags & BFTW_WHITEOUTS) {
+ state->dir_flags |= BFS_DIR_WHITEOUTS;
+ }
+
SLIST_INIT(&state->dir_batch);
SLIST_INIT(&state->to_open);
SLIST_INIT(&state->to_read);
goto unpin;
}
- if (ioq_opendir(state->ioq, dir, dfd, file->name, 0, file) != 0) {
+ if (ioq_opendir(state->ioq, dir, dfd, file->name, state->dir_flags, file) != 0) {
goto free;
}
return NULL;
}
- if (bfs_opendir(dir, fd, NULL, 0) != 0) {
+ if (bfs_opendir(dir, fd, NULL, state->dir_flags) != 0) {
bftw_freedir(cache, dir);
return NULL;
}
DEBUG_FLAG(flags, BFTW_PRUNE_MOUNTS);
DEBUG_FLAG(flags, BFTW_SORT);
DEBUG_FLAG(flags, BFTW_BUFFER);
+ DEBUG_FLAG(flags, BFTW_WHITEOUTS);
bfs_assert(flags == 0, "Missing bftw flag 0x%X", flags);
}