aboutsummaryrefslogtreecommitdiffstats
path: root/example
diff options
context:
space:
mode:
authorCismonX <admin@cismon.net>2025-07-09 23:10:03 +0800
committerBernd Schubert <bernd@bsbernd.com>2025-07-13 15:22:29 +0200
commitfc9888e0b281dc0d0fcebcfe0c8c392263b1b308 (patch)
treec01fbbde2f3c9627d21f320a3aa45a256b31bc21 /example
parent21a27e371fbb44e16eec6ef5e18768b476db2e27 (diff)
downloadlibfuse-fc9888e0b281dc0d0fcebcfe0c8c392263b1b308.tar.gz
example/passthrough: support fspacectl()
FreeBSD 14 introduced a new system call, fspacectl(). Currently, it supports one operation mode, SPACECTL_DEALLOC, which is functionally equivalent to Linux fallocate() with FALLOC_FL_KEEP_SIZE|FALLOC_FL_PUNCH_HOLE flags. fspacectl() calls with SPACECTL_DEALLOC is supported on FUSE filesystems via FUSE_FALLOCATE with the aforementioned flags. Signed-off-by: CismonX <admin@cismon.net>
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
}