aboutsummaryrefslogtreecommitdiffstats
path: root/example
diff options
context:
space:
mode:
Diffstat (limited to 'example')
-rw-r--r--example/passthrough_helpers.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/example/passthrough_helpers.h b/example/passthrough_helpers.h
index 52958c6..326a5c7 100644
--- a/example/passthrough_helpers.h
+++ b/example/passthrough_helpers.h
@@ -50,6 +50,19 @@ static inline int do_fallocate(int fd, int mode, off_t offset, off_t length)
return -posix_fallocate(fd, offset, length);
#endif
+#ifdef HAVE_FSPACECTL
+ // 0x3 == FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE
+ if (mode == 0x3) {
+ struct spacectl_range sr;
+
+ sr.r_offset = offset;
+ sr.r_len = length;
+ if (fspacectl(fd, SPACECTL_DEALLOC, &sr, 0, NULL) == -1)
+ return -errno;
+ return 0;
+ }
+#endif
+
return -EOPNOTSUPP;
#endif // HAVE_FALLOCATE
}