diff options
author | Nikolaus Rath <Nikolaus@rath.org> | 2017-04-07 16:27:59 -0700 |
---|---|---|
committer | Nikolaus Rath <Nikolaus@rath.org> | 2017-04-07 16:40:15 -0700 |
commit | 76218eb4614146b52f59563e85e6b5971acbfe92 (patch) | |
tree | 045af21a520f7d2d4596b25707f587963dee2e3e /example | |
parent | db1c6adb18950c188fbf20247245eef11ad47b30 (diff) |
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).
Diffstat (limited to 'example')
-rw-r--r-- | example/passthrough.c | 6 |
1 files changed, 4 insertions, 2 deletions
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; |