summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/eval.c b/eval.c
index 66ba895..f69c890 100644
--- a/eval.c
+++ b/eval.c
@@ -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;
}