summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Koch <nioko1337@gmail.com>2018-05-16 10:27:14 +0200
committerNicolas Koch <nioko1337@gmail.com>2018-05-16 10:27:14 +0200
commitf4c2825c8f80eae6ef18eb3fa30464a18a588e0f (patch)
tree67d192f5c8606c7baa2111b259a05746efda5a42
parentAdd clarifying comment about offset argument (diff)
downloadgrust-f4c2825c8f80eae6ef18eb3fa30464a18a588e0f.tar.gz
grust-f4c2825c8f80eae6ef18eb3fa30464a18a588e0f.tar.bz2
grust-f4c2825c8f80eae6ef18eb3fa30464a18a588e0f.tar.xz
Adjust len in every iteration
-rw-r--r--src/libstd/sys/unix/fs.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs
index 0649a147ea..c9d187f2ff 100644
--- a/src/libstd/sys/unix/fs.rs
+++ b/src/libstd/sys/unix/fs.rs
@@ -815,6 +815,7 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
815 815
816 let mut written = 0u64; 816 let mut written = 0u64;
817 while written < len { 817 while written < len {
818 let bytes_to_copy = len - written;
818 let copy_result = unsafe { 819 let copy_result = unsafe {
819 // We actually don't have to adjust the offsets, 820 // We actually don't have to adjust the offsets,
820 // because copy_file_range adjusts the file offset automatically 821 // because copy_file_range adjusts the file offset automatically
@@ -822,7 +823,7 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
822 ptr::null_mut(), 823 ptr::null_mut(),
823 writer.as_raw_fd(), 824 writer.as_raw_fd(),
824 ptr::null_mut(), 825 ptr::null_mut(),
825 len as usize, 826 bytes_to_copy as usize,
826 0) 827 0)
827 ) 828 )
828 }; 829 };