-static int copy_data_forward(int fd_old, int fd_new, size_t block_size, void *buf)
+void print_progress(uint64_t bytes, int final)
+{
+ uint64_t mbytes = bytes / 1024 / 1024;
+ struct timeval now_time;
+ double tdiff;
+
+ gettimeofday(&now_time, NULL);
+ if (!final && time_diff(rnc.end_time, now_time) < 0.5)
+ return;
+
+ rnc.end_time = now_time;
+
+ if (opt_batch_mode)
+ return;
+
+ tdiff = time_diff(rnc.start_time, rnc.end_time);
+ if (!tdiff)
+ return;
+
+ log_err("\33[2K\rProgress: %5.1f%%, time elapsed %3.1f seconds, %4"
+ PRIu64 " MB written, speed %5.2f MB/s%s",
+ (double)bytes / rnc.device_size * 100,
+ time_diff(rnc.start_time, rnc.end_time),
+ mbytes, (double)(mbytes) / tdiff,
+ final ? "\n" :"");
+}
+
+static int copy_data_forward(int fd_old, int fd_new, size_t block_size, void *buf, uint64_t *bytes)