summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2016-02-04 17:18:16 -0500
committerTavian Barnes <tavianator@tavianator.com>2016-02-04 17:18:16 -0500
commitff87f3cdf1e3c5a7d4661e785f4d96be9d59291c (patch)
treec08ec3fb6ba60ce424dc3ef81671981ceed824fa
parentd696346689e161ee8a5623182ed65ab119adb203 (diff)
downloadbfs-ff87f3cdf1e3c5a7d4661e785f4d96be9d59291c.tar.xz
Implement -inum.
-rw-r--r--bfs.h1
-rw-r--r--eval.c12
-rw-r--r--parse.c2
3 files changed, 15 insertions, 0 deletions
diff --git a/bfs.h b/bfs.h
index 6c691b4..4b558d8 100644
--- a/bfs.h
+++ b/bfs.h
@@ -153,6 +153,7 @@ bool eval_uid(const struct expr *expr, struct eval_state *state);
bool eval_empty(const struct expr *expr, struct eval_state *state);
bool eval_hidden(const struct expr *expr, struct eval_state *state);
+bool eval_inum(const struct expr *expr, struct eval_state *state);
bool eval_type(const struct expr *expr, struct eval_state *state);
bool eval_name(const struct expr *expr, struct eval_state *state);
diff --git a/eval.c b/eval.c
index 33da8e4..a60bd30 100644
--- a/eval.c
+++ b/eval.c
@@ -273,6 +273,18 @@ bool eval_nohidden(const struct expr *expr, struct eval_state *state) {
}
/**
+ * -inum test.
+ */
+bool eval_inum(const struct expr *expr, struct eval_state *state) {
+ const struct stat *statbuf = fill_statbuf(state);
+ if (!statbuf) {
+ return false;
+ }
+
+ return do_cmp(expr, statbuf->st_ino);
+}
+
+/**
* -name test.
*/
bool eval_name(const struct expr *expr, struct eval_state *state) {
diff --git a/parse.c b/parse.c
index da9ee9c..0cceef4 100644
--- a/parse.c
+++ b/parse.c
@@ -499,6 +499,8 @@ static struct expr *parse_literal(struct parser_state *state) {
return new_test(state, eval_hidden);
} else if (strcmp(arg, "-nohidden") == 0) {
return new_action(state, eval_nohidden);
+ } else if (strcmp(arg, "-inum") == 0) {
+ return parse_test_icmp(state, arg, eval_inum);
} else if (strcmp(arg, "-mindepth") == 0) {
return parse_depth(state, arg, &state->cl->mindepth);
} else if (strcmp(arg, "-maxdepth") == 0) {