diff options
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; } |