aboutsummaryrefslogtreecommitdiffstats
path: root/example/passthrough.c
diff options
context:
space:
mode:
authorYuri Per <yuri@acronis.com>2019-11-03 11:44:31 +0200
committerNikolaus Rath <Nikolaus@rath.org>2019-11-03 09:44:31 +0000
commitd735af94fa54a5555ce725f1d4e6b97b812b6603 (patch)
treecb21ee1eceb66e1c85a5c78ae7aa4a5f9438274a /example/passthrough.c
parentb9c584370aa489ac00b1e8a0454c61f30c0531af (diff)
downloadlibfuse-d735af94fa54a5555ce725f1d4e6b97b812b6603.tar.gz
Implement lseek operation (#457)
Diffstat (limited to 'example/passthrough.c')
-rw-r--r--example/passthrough.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/example/passthrough.c b/example/passthrough.c
index 6de9fc1..012bd31 100644
--- a/example/passthrough.c
+++ b/example/passthrough.c
@@ -484,6 +484,28 @@ static ssize_t xmp_copy_file_range(const char *path_in,
}
#endif
+static off_t xmp_lseek(const char *path, off_t off, int whence, struct fuse_file_info *fi)
+{
+ int fd;
+ off_t res;
+
+ if (fi == NULL)
+ fd = open(path, O_RDONLY);
+ else
+ fd = fi->fh;
+
+ if (fd == -1)
+ return -errno;
+
+ res = lseek(fd, off, whence);
+ if (res == -1)
+ res = -errno;
+
+ if (fi == NULL)
+ close(fd);
+ return res;
+}
+
static struct fuse_operations xmp_oper = {
.init = xmp_init,
.getattr = xmp_getattr,
@@ -522,6 +544,7 @@ static struct fuse_operations xmp_oper = {
#ifdef HAVE_COPY_FILE_RANGE
.copy_file_range = xmp_copy_file_range,
#endif
+ .lseek = xmp_lseek,
};
int main(int argc, char *argv[])