From 76218eb4614146b52f59563e85e6b5971acbfe92 Mon Sep 17 00:00:00 2001 From: Nikolaus Rath Date: Fri, 7 Apr 2017 16:27:59 -0700 Subject: passthrough:truncate(): work on file descriptor when possible This allows truncating an open file even if write permission was removed after open() (which is the expected behavior). --- example/passthrough.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'example') diff --git a/example/passthrough.c b/example/passthrough.c index 55f7704..67663ab 100644 --- a/example/passthrough.c +++ b/example/passthrough.c @@ -250,10 +250,12 @@ static int xmp_chown(const char *path, uid_t uid, gid_t gid, static int xmp_truncate(const char *path, off_t size, struct fuse_file_info *fi) { - (void) fi; int res; - res = truncate(path, size); + if (fi != NULL) + res = ftruncate(fi->fh, size); + else + res = truncate(path, size); if (res == -1) return -errno; -- cgit v1.2.3