summaryrefslogtreecommitdiffstats
path: root/usr.bin/find/function.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/find/function.c')
-rw-r--r--usr.bin/find/function.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c
index cad6eb1..61d61cb 100644
--- a/usr.bin/find/function.c
+++ b/usr.bin/find/function.c
@@ -1497,6 +1497,29 @@ c_size(OPTION *option, char ***argvp)
}
/*
+ * -sparse functions --
+ *
+ * Check if a file is sparse by finding if it occupies fewer blocks
+ * than we expect based on its size.
+ */
+int
+f_sparse(PLAN *plan __unused, FTSENT *entry)
+{
+ off_t expected_blocks;
+
+ expected_blocks = (entry->fts_statp->st_size + 511) / 512;
+ return entry->fts_statp->st_blocks < expected_blocks;
+}
+
+PLAN *
+c_sparse(OPTION *option, char ***argvp __unused)
+{
+ ftsoptions &= ~FTS_NOSTAT;
+
+ return palloc(option);
+}
+
+/*
* -type c functions --
*
* True if the type of the file is c, where c is b, c, d, p, f or w
OpenPOWER on IntegriCloud