summaryrefslogtreecommitdiffstats
path: root/bftw.c
diff options
context:
space:
mode:
Diffstat (limited to 'bftw.c')
-rw-r--r--bftw.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/bftw.c b/bftw.c
index d2a73d6..8a55f13 100644
--- a/bftw.c
+++ b/bftw.c
@@ -635,6 +635,7 @@ static void bftw_init_buffers(struct bftw_state *state, const struct dirent *de)
}
bool follow = state->flags & (current ? BFTW_FOLLOW_NONROOT : BFTW_FOLLOW_ROOT);
+ ftwbuf->at_flags = follow ? 0 : AT_SYMLINK_NOFOLLOW;
bool detect_cycles = (state->flags & BFTW_DETECT_CYCLES)
&& state->status == BFTW_CHILD;
@@ -643,13 +644,10 @@ static void bftw_init_buffers(struct bftw_state *state, const struct dirent *de)
|| ftwbuf->typeflag == BFTW_UNKNOWN
|| (ftwbuf->typeflag == BFTW_LNK && follow)
|| (ftwbuf->typeflag == BFTW_DIR && detect_cycles)) {
- int flags = follow ? 0 : AT_SYMLINK_NOFOLLOW;
-
- int ret = ftwbuf_stat(ftwbuf, &state->statbuf, flags);
+ int ret = ftwbuf_stat(ftwbuf, &state->statbuf, ftwbuf->at_flags);
if (ret != 0 && follow && errno == ENOENT) {
// Could be a broken symlink, retry without following
- flags = AT_SYMLINK_NOFOLLOW;
- ret = ftwbuf_stat(ftwbuf, &state->statbuf, flags);
+ ret = ftwbuf_stat(ftwbuf, &state->statbuf, AT_SYMLINK_NOFOLLOW);
}
if (ret != 0) {