summaryrefslogtreecommitdiff
path: root/example/fusexmp_fh.c
diff options
context:
space:
mode:
authorAnatol Pomozov <anatol.pomozov@gmail.com>2012-04-22 18:49:35 -0700
committerMiklos Szeredi <mszeredi@suse.cz>2012-06-18 13:32:43 +0200
commit96ac0e5d76db3714b7c8d37956f6e6b1d804a01a (patch)
tree4cd918bccb54e30edca0dadbe2b44a43b7ef1c91 /example/fusexmp_fh.c
parent46b9c3326d50aebe52c33d63885b83a47a2e74ea (diff)
downloadfuse-96ac0e5d76db3714b7c8d37956f6e6b1d804a01a.tar.gz
Add FALLOCATE operation
fallocate filesystem operation preallocates media space for the given file. If fallocate returns success then any subsequent write to the given range never fails with 'not enough space' error.
Diffstat (limited to 'example/fusexmp_fh.c')
-rw-r--r--example/fusexmp_fh.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/example/fusexmp_fh.c b/example/fusexmp_fh.c
index d79ff37..1ba9dbc 100644
--- a/example/fusexmp_fh.c
+++ b/example/fusexmp_fh.c
@@ -439,6 +439,19 @@ 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);
+}
+#endif
+
#ifdef HAVE_SETXATTR
/* xattr operations are optional and can safely be left unimplemented */
static int xmp_setxattr(const char *path, const char *name, const char *value,
@@ -529,6 +542,9 @@ static 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,