From db5a1b6ae9d39614154590e5b8c62702a5230ca4 Mon Sep 17 00:00:00 2001 From: CismonX Date: Wed, 9 Jul 2025 23:01:05 +0800 Subject: example/passthrough: refactor fallocate Move fallocate implementation to passthrough_helpers.h, so that it could be reused by multiple passthrough examples. Signed-off-by: CismonX --- example/passthrough_hp.cc | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'example/passthrough_hp.cc') diff --git a/example/passthrough_hp.cc b/example/passthrough_hp.cc index cc6b7e8..a0bf0d5 100644 --- a/example/passthrough_hp.cc +++ b/example/passthrough_hp.cc @@ -79,6 +79,8 @@ #include #include +#include "passthrough_helpers.h" + using namespace std; #define SFS_DEFAULT_THREADS "-1" // take libfuse value as default @@ -1216,20 +1218,15 @@ static void sfs_statfs(fuse_req_t req, fuse_ino_t ino) fuse_reply_statfs(req, &stbuf); } -#ifdef HAVE_POSIX_FALLOCATE static void sfs_fallocate(fuse_req_t req, fuse_ino_t ino, int mode, off_t offset, off_t length, fuse_file_info *fi) { (void)ino; - if (mode) { - fuse_reply_err(req, EOPNOTSUPP); - return; - } - auto err = posix_fallocate(fi->fh, offset, length); + auto err = -do_fallocate(fi->fh, mode, offset, length); + fuse_reply_err(req, err); } -#endif static void sfs_flock(fuse_req_t req, fuse_ino_t ino, fuse_file_info *fi, int op) @@ -1389,9 +1386,7 @@ static void assign_operations(fuse_lowlevel_ops &sfs_oper) sfs_oper.read = sfs_read; sfs_oper.write_buf = sfs_write_buf; sfs_oper.statfs = sfs_statfs; -#ifdef HAVE_POSIX_FALLOCATE sfs_oper.fallocate = sfs_fallocate; -#endif sfs_oper.flock = sfs_flock; #ifdef HAVE_SETXATTR sfs_oper.setxattr = sfs_setxattr; -- cgit v1.2.3