
Description
Currently std::fs::copy
is using (edit: it tries std::io::copy
to copy files - it reads the file content into the memory, and then write it to the output file. std::fs::copy
orcopy_file_range(2)
first and has already benefited from the file cloning feature) std::io::copy
can benefit from the file cloning feature in Btrfs and XFS by using FICLONE
(and fallbacking to read-write loop if the filesystem does not support it).
I think is easy to use FICLONE
in std::fs::copy
, but it's less general (it requires file paths). std::io::copy
is more general, but some additional methods may be needed to be added to std::io::Read
and std::io::Write
in order to use FICLONE
.
libuv's support for FICLONE
: libuv/libuv#1491
The ioctl_ficlonerange(2)
man page: https://www.man7.org/linux/man-pages/man2/ioctl_ficlonerange.2.html