Skip to main content

clone_range

Function clone_range 

Source
pub fn clone_range(
    src: BorrowedFd<'_>,
    src_offset: u64,
    length: u64,
    dst: BorrowedFd<'_>,
    dst_offset: u64,
) -> Result<()>
Expand description

Reflink a range of bytes from src to dst.

A length of zero is a sentinel meaning “from src_offset to end-of-source-file” — this matches the kernel’s documented behaviour. The source and destination can be the same file.

§Errors

Common errors: EINVAL if offsets or length are not block- aligned (filesystem-specific; btrfs requires sector alignment for non-tail extents), EXDEV if the files live on different filesystems, EPERM if the destination is not writable, or EOPNOTSUPP if the filesystem doesn’t support reflinks.