aboutsummaryrefslogtreecommitdiffstats
path: root/example
diff options
context:
space:
mode:
Diffstat (limited to 'example')
-rw-r--r--example/passthrough.c23
-rw-r--r--example/passthrough_fh.c13
-rw-r--r--example/passthrough_ll.c14
3 files changed, 50 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[])
diff --git a/example/passthrough_fh.c b/example/passthrough_fh.c
index 3fc80f8..13eb41e 100644
--- a/example/passthrough_fh.c
+++ b/example/passthrough_fh.c
@@ -596,6 +596,18 @@ 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)
+{
+ off_t res;
+ (void) path;
+
+ res = lseek(fi->fh, off, whence);
+ if (res == -1)
+ return -errno;
+
+ return res;
+}
+
static struct fuse_operations xmp_oper = {
.init = xmp_init,
.getattr = xmp_getattr,
@@ -643,6 +655,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[])
diff --git a/example/passthrough_ll.c b/example/passthrough_ll.c
index 0f1fda5..5372d02 100644
--- a/example/passthrough_ll.c
+++ b/example/passthrough_ll.c
@@ -1161,6 +1161,19 @@ static void lo_copy_file_range(fuse_req_t req, fuse_ino_t ino_in, off_t off_in,
}
#endif
+static void lo_lseek(fuse_req_t req, fuse_ino_t ino, off_t off, int whence,
+ struct fuse_file_info *fi)
+{
+ off_t res;
+
+ (void)ino;
+ res = lseek(fi->fh, off, whence);
+ if (res != -1)
+ fuse_reply_lseek(req, res);
+ else
+ fuse_reply_err(req, errno);
+}
+
static struct fuse_lowlevel_ops lo_oper = {
.init = lo_init,
.lookup = lo_lookup,
@@ -1198,6 +1211,7 @@ static struct fuse_lowlevel_ops lo_oper = {
#ifdef HAVE_COPY_FILE_RANGE
.copy_file_range = lo_copy_file_range,
#endif
+ .lseek = lo_lseek,
};
int main(int argc, char *argv[])