aboutsummaryrefslogtreecommitdiffstats
path: root/example/passthrough_fh.c
diff options
context:
space:
mode:
authorCismonX <admin@cismon.net>2025-07-09 23:01:05 +0800
committerBernd Schubert <bernd@bsbernd.com>2025-07-13 15:22:29 +0200
commitdb5a1b6ae9d39614154590e5b8c62702a5230ca4 (patch)
treec0685f8f67bfd301ec0eb417f0cf647bc692d64a /example/passthrough_fh.c
parent4166f2eb97da4e25a516abee3d6fe13b9ed77bc6 (diff)
downloadlibfuse-db5a1b6ae9d39614154590e5b8c62702a5230ca4.tar.gz
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 <admin@cismon.net>
Diffstat (limited to 'example/passthrough_fh.c')
-rw-r--r--example/passthrough_fh.c11
1 files changed, 3 insertions, 8 deletions
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 <sys/file.h> /* 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,