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_fh.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'example/passthrough_fh.c') diff --git a/example/passthrough_fh.c b/example/passthrough_fh.c index 7bbdb70..6764554 100644 --- a/example/passthrough_fh.c +++ b/example/passthrough_fh.c @@ -47,6 +47,8 @@ #endif #include /* flock(2) */ +#include "passthrough_helpers.h" + static void *xmp_init(struct fuse_conn_info *conn, struct fuse_config *cfg) { @@ -514,18 +516,13 @@ static int xmp_fsync(const char *path, int isdatasync, return 0; } -#ifdef HAVE_POSIX_FALLOCATE static int xmp_fallocate(const char *path, int mode, off_t offset, off_t length, struct fuse_file_info *fi) { (void) path; - if (mode) - return -EOPNOTSUPP; - - return -posix_fallocate(fi->fh, offset, length); + return do_fallocate(fi->fh, mode, offset, length); } -#endif #ifdef HAVE_SETXATTR /* xattr operations are optional and can safely be left unimplemented */ @@ -650,9 +647,7 @@ static const struct fuse_operations xmp_oper = { .flush = xmp_flush, .release = xmp_release, .fsync = xmp_fsync, -#ifdef HAVE_POSIX_FALLOCATE .fallocate = xmp_fallocate, -#endif #ifdef HAVE_SETXATTR .setxattr = xmp_setxattr, .getxattr = xmp_getxattr, -- cgit v1.2.3