projects
/
qemu-gpiodev
/
libfuse.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
db1c6ad
)
passthrough:truncate(): work on file descriptor when possible
author
Nikolaus Rath
<Nikolaus@rath.org>
Fri, 7 Apr 2017 23:27:59 +0000
(16:27 -0700)
committer
Nikolaus Rath
<Nikolaus@rath.org>
Fri, 7 Apr 2017 23:40:15 +0000
(16:40 -0700)
This allows truncating an open file even if write permission
was removed after open() (which is the expected behavior).
example/passthrough.c
patch
|
blob
|
history
diff --git
a/example/passthrough.c
b/example/passthrough.c
index 55f770415a6f7d5332a9ed5bc30fca5106de3062..67663abb76a59e7cd7b66bc21ea7c5db1ff4e7f1 100644
(file)
--- 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;