diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2016-02-22 14:13:26 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2016-02-22 14:13:26 -0500 |
commit | 275fbdbe040dc07b2705c92d4cd24ad3f3c7d069 (patch) | |
tree | 0fd997ea04f5ef16c22941d2aabbc01d900073fe /eval.c | |
parent | 59f46665aa10eed0776e93dc5f67368a3b8b27e3 (diff) | |
download | bfs-275fbdbe040dc07b2705c92d4cd24ad3f3c7d069.tar.xz |
Implement -D stat.
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 31 |
1 files changed, 31 insertions, 0 deletions
@@ -520,6 +520,33 @@ bool eval_comma(const struct expr *expr, struct eval_state *state) { } /** + * Debug stat() calls. + */ +void debug_stat(const struct eval_state *state) { + struct BFTW *ftwbuf = state->ftwbuf; + + fprintf(stderr, "fstatat("); + if (ftwbuf->at_fd == AT_FDCWD) { + fprintf(stderr, "AT_FDCWD"); + } else { + size_t baselen = strlen(ftwbuf->path) - strlen(ftwbuf->at_path); + fprintf(stderr, "\""); + fwrite(ftwbuf->path, 1, baselen, stderr); + fprintf(stderr, "\""); + } + + fprintf(stderr, ", \"%s\", ", ftwbuf->at_path); + + if (ftwbuf->at_flags == AT_SYMLINK_NOFOLLOW) { + fprintf(stderr, "AT_SYMLINK_NOFOLLOW"); + } else { + fprintf(stderr, "%d", ftwbuf->at_flags); + } + + fprintf(stderr, ")\n"); +} + +/** * Type passed as the argument to the bftw() callback. */ struct callback_args { @@ -567,6 +594,10 @@ static enum bftw_action cmdline_callback(struct BFTW *ftwbuf, void *ptr) { eval_expr(cmdline->expr, &state); } + if ((cmdline->debug & DEBUG_STAT) && ftwbuf->statbuf) { + debug_stat(&state); + } + args->ret = state.ret; return state.action; } |