Skip to content

Commit f4c2825

Browse files
committed
Adjust len in every iteration
1 parent b605923 commit f4c2825

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/libstd/sys/unix/fs.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -815,14 +815,15 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
815815

816816
let mut written = 0u64;
817817
while written < len {
818+
let bytes_to_copy = len - written;
818819
let copy_result = unsafe {
819820
// We actually don't have to adjust the offsets,
820821
// because copy_file_range adjusts the file offset automatically
821822
cvt(copy_file_range(reader.as_raw_fd(),
822823
ptr::null_mut(),
823824
writer.as_raw_fd(),
824825
ptr::null_mut(),
825-
len as usize,
826+
bytes_to_copy as usize,
826827
0)
827828
)
828829
};

0 commit comments

Comments
 (0)