summaryrefslogtreecommitdiff
path: root/example/passthrough.c
diff options
context:
space:
mode:
authorAlan Somers <asomers@gmail.com>2021-01-01 12:34:58 -0700
committerGitHub <noreply@github.com>2021-01-01 19:34:58 +0000
commitccba27fbec00d253102395cbdab048f0553c1938 (patch)
tree8639e203abc3eaa2af6ebb4730bc9b95f89bac90 /example/passthrough.c
parentb96e4758041ffac1b8d8c39f4897edd6182a46e9 (diff)
downloadfuse-ccba27fbec00d253102395cbdab048f0553c1938.tar.gz
Fix FUSE_COPY_FILE_RANGE in the passthrough example (#575)
Only close the file descriptors if they were just opened. Otherwise, the second FUSE_COPY_FILE_RANGE operation on any given file will fail with EBADF.
Diffstat (limited to 'example/passthrough.c')
-rw-r--r--example/passthrough.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/example/passthrough.c b/example/passthrough.c
index 85cca5e..08273ff 100644
--- a/example/passthrough.c
+++ b/example/passthrough.c
@@ -477,8 +477,10 @@ static ssize_t xmp_copy_file_range(const char *path_in,
if (res == -1)
res = -errno;
- close(fd_in);
- close(fd_out);
+ if (fi_out == NULL)
+ close(fd_out);
+ if (fi_in == NULL)
+ close(fd_in);
return res;
}