summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2016-02-22 14:13:26 -0500
committerTavian Barnes <tavianator@tavianator.com>2016-02-22 14:13:26 -0500
commit275fbdbe040dc07b2705c92d4cd24ad3f3c7d069 (patch)
tree0fd997ea04f5ef16c22941d2aabbc01d900073fe /eval.c
parent59f46665aa10eed0776e93dc5f67368a3b8b27e3 (diff)
downloadbfs-275fbdbe040dc07b2705c92d4cd24ad3f3c7d069.tar.xz
Implement -D stat.
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;
}