--- coreutils-8.5/src/copy.c 2010-04-20 23:52:04.000000000 +0400 +++ copy.c 2010-09-12 17:50:57.544775657 +0400 @@ -709,6 +709,20 @@ buf_alloc = xmalloc (buf_size + buf_alignment_slop); buf = ptr_align (buf_alloc, buf_alignment); + int counter=0; + int writes_per_percent; + bool print_progress = false; + + //decide should we print progress bar + if ((x->verbose) && (src_open_sb.st_size > 0)) + print_progress = true; + + //calculate number of writes per one percent of copy progress + if (print_progress) + { + writes_per_percent = (int)src_open_sb.st_size / (int)buf_size / 100; + printf("%d bytes: ",(int)src_open_sb.st_size); + } for (;;) { word *wp = NULL; @@ -783,15 +797,29 @@ return_val = false; goto close_src_and_dst_desc; } + + //print dot per percent of copy progress + if ((print_progress) && ((counter >= writes_per_percent) || (counter == 0))) + { + counter=0; + printf("*"); + fflush(stdout); + } + counter++; + last_write_made_hole = false; /* It is tempting to return early here upon a short read from a regular file. That would save the final read syscall for each file. Unfortunately that doesn't work for certain files in /proc with linux kernels from at least 2.6.9 .. 2.6.29. */ - } + } } - + + //print newline after line of dots + if (print_progress) + printf(" Done!\n"); + /* If the file ends with a `hole', we need to do something to record the length of the file. On modern systems, calling ftruncate does the job. On systems without native ftruncate support, we have to