Function nix::fcntl::copy_file_range
source ยท pub fn copy_file_range<Fd1: AsFd, Fd2: AsFd>(
fd_in: Fd1,
off_in: Option<&mut i64>,
fd_out: Fd2,
off_out: Option<&mut i64>,
len: usize,
) -> Result<usize>
Expand description
Copy a range of data from one file to another
The copy_file_range
system call performs an in-kernel copy between
file descriptors fd_in
and fd_out
without the additional cost of
transferring data from the kernel to user space and back again. There may be
additional optimizations for specific file systems. It copies up to len
bytes of data from file descriptor fd_in
to file descriptor fd_out
,
overwriting any data that exists within the requested range of the target
file.
If the off_in
and/or off_out
arguments are used, the values
will be mutated to reflect the new position within the file after
copying. If they are not used, the relevant file descriptors will be seeked
to the new position.
On successful completion the number of bytes actually copied will be returned.