aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--example/passthrough_helpers.h13
-rw-r--r--meson.build2
2 files changed, 14 insertions, 1 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
}
diff --git a/meson.build b/meson.build
index 910a075..16b804e 100644
--- a/meson.build
+++ b/meson.build
@@ -74,7 +74,7 @@ private_cfg.set_quoted('PACKAGE_VERSION', meson.project_version())
# Test for presence of some functions
test_funcs = [ 'fork', 'fstatat', 'openat', 'readlinkat', 'pipe2',
'splice', 'vmsplice', 'posix_fallocate', 'fdatasync',
- 'utimensat', 'copy_file_range', 'fallocate' ]
+ 'utimensat', 'copy_file_range', 'fallocate', 'fspacectl' ]
foreach func : test_funcs
private_cfg.set('HAVE_' + func.to_upper(),
cc.has_function(func, prefix: include_default, args: args_default))