diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2016-02-13 12:34:08 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2016-02-13 12:49:38 -0500 |
commit | 55fb616348d114a1451ab6cf502a3768d6284e9a (patch) | |
tree | ef5f72632be59a2acb903c6ba7ef8f8355474f6d /bftw.c | |
parent | 603b9da0a0ef485393e9fb9fa14c139cedbe92d0 (diff) | |
download | bfs-55fb616348d114a1451ab6cf502a3768d6284e9a.tar.xz |
Follow links if appropriate in predicates.
Diffstat (limited to 'bftw.c')
-rw-r--r-- | bftw.c | 8 |
1 files changed, 3 insertions, 5 deletions
@@ -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) { |