From fe4f9428fc403fa8b99051f52d84ea5bd13f3855 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Mon, 18 Jun 2018 19:31:43 +0200 Subject: libfuse: add copy_file_range() support Add support for the relatively new copy_file_range() syscall. Backend filesystems can now implement an efficient way of cloning/duplicating data ranges within files. See 'man 2 copy_file_range' for more details. --- include/fuse.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'include/fuse.h') diff --git a/include/fuse.h b/include/fuse.h index 24e04bc..d3644ad 100644 --- a/include/fuse.h +++ b/include/fuse.h @@ -750,6 +750,23 @@ struct fuse_operations { */ int (*fallocate) (const char *, int, off_t, off_t, struct fuse_file_info *); + + /** + * Copy a range of data from one file to another + * + * Performs an optimized copy between two file descriptors without the + * additional cost of transferring data through the FUSE kernel module + * to user space (glibc) and then back into the FUSE filesystem again. + * + * In case this method is not implemented, glibc falls back to reading + * data from the source and writing to the destination. Effectively + * doing an inefficient copy of the data. + */ + ssize_t (*copy_file_range) (const char *path_in, + struct fuse_file_info *fi_in, + off_t offset_in, const char *path_out, + struct fuse_file_info *fi_out, + off_t offset_out, size_t size, int flags); }; /** Extra context that may be needed by some filesystems @@ -1165,6 +1182,11 @@ int fuse_fs_poll(struct fuse_fs *fs, const char *path, unsigned *reventsp); int fuse_fs_fallocate(struct fuse_fs *fs, const char *path, int mode, off_t offset, off_t length, struct fuse_file_info *fi); +ssize_t fuse_fs_copy_file_range(struct fuse_fs *fs, const char *path_in, + struct fuse_file_info *fi_in, off_t off_in, + const char *path_out, + struct fuse_file_info *fi_out, off_t off_out, + size_t len, int flags); void fuse_fs_init(struct fuse_fs *fs, struct fuse_conn_info *conn, struct fuse_config *cfg); void fuse_fs_destroy(struct fuse_fs *fs); -- cgit v1.2.3