From: Alan Somers Date: Fri, 1 Jan 2021 19:34:58 +0000 (-0700) Subject: Fix FUSE_COPY_FILE_RANGE in the passthrough example (#575) X-Git-Tag: fuse-3.10.2~7 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=ccba27fbec00d253102395cbdab048f0553c1938;p=qemu-gpiodev%2Flibfuse.git 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. --- 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; }