summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2016-12-20 21:23:02 -0500
committerTavian Barnes <tavianator@tavianator.com>2016-12-20 21:23:02 -0500
commit0609e6f29719a7e88b8233d6bd5b75509a2d59f5 (patch)
treed47936c46a7cf9a4db81ae61aa725c73e5d7f3d3 /eval.c
parent96ca12560f5c4007891985f98fba94fd9c0dc241 (diff)
downloadbfs-0609e6f29719a7e88b8233d6bd5b75509a2d59f5.tar.xz
Implement -sparse from FreeBSD find
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/eval.c b/eval.c
index b62c1b4..2497455 100644
--- a/eval.c
+++ b/eval.c
@@ -818,6 +818,19 @@ bool eval_size(const struct expr *expr, struct eval_state *state) {
}
/**
+ * -sparse test.
+ */
+bool eval_sparse(const struct expr *expr, struct eval_state *state) {
+ const struct stat *statbuf = fill_statbuf(state);
+ if (!statbuf) {
+ return false;
+ }
+
+ blkcnt_t expected = (statbuf->st_size + 511)/512;
+ return statbuf->st_blocks < expected;
+}
+
+/**
* -type test.
*/
bool eval_type(const struct expr *expr, struct eval_state *state) {