+ return total_bytes;
+}
+
+/*
+ * show_rate: displays the current read/write file name and performance,
+ * along with an estimate of how long the whole read/write operation
+ * will continue.
+ */
+void show_rate(char *op, char *filename, const struct timeval *start_time,
+ const unsigned long long total_bytes,
+ const unsigned long long curr_bytes)
+{
+ static struct timeval last_time;
+ static unsigned long long last_bytes;
+ static char last_op;
+ struct timeval curr_time;
+ double curr_delta, overall_delta, curr_rate, overall_rate;
+ double total_time, remain_time;
+ int remain_hours, remain_minutes, remain_seconds;
+
+ if (last_time.tv_sec == 0)
+ last_time = *start_time;
+
+ if (last_op != op[0]) {
+ last_bytes = 0;
+ last_time = *start_time;
+ last_op = op[0];
+ }
+
+ gettimeofday(&curr_time, NULL);
+
+ curr_delta = (curr_time.tv_sec - last_time.tv_sec) +
+ (double)(curr_time.tv_usec - last_time.tv_usec) / 1000000;
+
+ overall_delta = (curr_time.tv_sec - start_time->tv_sec) +
+ (double)(curr_time.tv_usec - start_time->tv_usec) / 1000000;
+
+ curr_rate = (curr_bytes - last_bytes) / curr_delta;
+ overall_rate = curr_bytes / overall_delta;
+
+ if (curr_rate == 0) {
+ last_time = curr_time;
+ return;
+ }
+ total_time = total_bytes / curr_rate;
+ remain_time = total_time - overall_delta;
+
+ remain_hours = remain_time / 3600;
+ remain_minutes = (remain_time - remain_hours * 3600) / 60;
+ remain_seconds = (remain_time - remain_hours * 3600 -
+ remain_minutes * 60);
+
+ if (curr_delta > 4 || verbose > 2) {