diff options
author | Liu Bo <liub.liubo@gmail.com> | 2019-04-18 01:55:42 -0700 |
---|---|---|
committer | Nikolaus Rath <Nikolaus@rath.org> | 2019-04-18 09:55:42 +0100 |
commit | 5fc562c90d7925963467babbb73ae5b4f9fd13f8 (patch) | |
tree | 40520fcf13262c62937db332958997ed86edf550 /example/passthrough_ll.c | |
parent | 9ec8e1c9406451262b6fd3c93787b2bb6d745ea5 (diff) | |
download | libfuse-5fc562c90d7925963467babbb73ae5b4f9fd13f8.tar.gz |
Add fallocate and use it instead of posix_fallocate if possible (#398)
fuse.ko has supported FALLOC_FL_KEEP_SIZE and FALLOC_FL_PUNCH_HOLE at this
moment and more modes may be supported in the future.
fallocate(2) supports modes while posix_fallocate(2) does not, so this
makes lo_fallocate use fallocate(2) instead.
Signed-off-by: Liu Bo <bo.liu@linux.alibaba.com>
Diffstat (limited to 'example/passthrough_ll.c')
-rw-r--r-- | example/passthrough_ll.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/example/passthrough_ll.c b/example/passthrough_ll.c index 1598958..b6ecaff 100644 --- a/example/passthrough_ll.c +++ b/example/passthrough_ll.c @@ -936,12 +936,19 @@ static void lo_fallocate(fuse_req_t req, fuse_ino_t ino, int mode, int err; (void) ino; +#ifdef HAVE_FALLOCATE + err = fallocate(fi->fh, mode, offset, length); + if (err < 0) + err = errno; + +#elif HAVE_POSIX_FALLOCATE if (mode) { fuse_reply_err(req, EOPNOTSUPP); return; } err = posix_fallocate(fi->fh, offset, length); +#endif fuse_reply_err(req, err); } |