summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bfs.h1
-rw-r--r--eval.c15
-rw-r--r--parse.c2
3 files changed, 18 insertions, 0 deletions
diff --git a/bfs.h b/bfs.h
index 3a85650..1e38869 100644
--- a/bfs.h
+++ b/bfs.h
@@ -187,6 +187,7 @@ bool eval_access(const struct expr *expr, struct eval_state *state);
bool eval_acmtime(const struct expr *expr, struct eval_state *state);
bool eval_acnewer(const struct expr *expr, struct eval_state *state);
+bool eval_used(const struct expr *expr, struct eval_state *state);
bool eval_gid(const struct expr *expr, struct eval_state *state);
bool eval_uid(const struct expr *expr, struct eval_state *state);
diff --git a/eval.c b/eval.c
index 81d2de7..aae82cd 100644
--- a/eval.c
+++ b/eval.c
@@ -174,6 +174,21 @@ bool eval_acnewer(const struct expr *expr, struct eval_state *state) {
}
/**
+ * -used test.
+ */
+bool eval_used(const struct expr *expr, struct eval_state *state) {
+ const struct stat *statbuf = fill_statbuf(state);
+ if (!statbuf) {
+ return false;
+ }
+
+ time_t diff = timespec_diff(&statbuf->st_atim, &statbuf->st_ctim);
+ diff /= 60*60*24;
+ printf("%d\n", (int)diff);
+ return do_cmp(expr, diff);
+}
+
+/**
* -gid test.
*/
bool eval_gid(const struct expr *expr, struct eval_state *state) {
diff --git a/parse.c b/parse.c
index 2fc4fd8..154d566 100644
--- a/parse.c
+++ b/parse.c
@@ -1065,6 +1065,8 @@ static struct expr *parse_literal(struct parser_state *state) {
case 'u':
if (strcmp(arg, "-uid") == 0) {
return parse_test_icmp(state, eval_uid);
+ } else if (strcmp(arg, "-used") == 0) {
+ return parse_test_icmp(state, eval_used);
} else if (strcmp(arg, "-user") == 0) {
return parse_user(state);
}