mirror of
https://github.com/libfuse/libfuse.git
synced 2026-07-07 14:47:41 +08:00
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>
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
+1
-1
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user