From 1e12a7c529b76ed6c8b34f3c2fb588192e9de184 Mon Sep 17 00:00:00 2001 From: Michael Wehr Date: Tue, 11 Jan 2022 20:53:17 +0100 Subject: [PATCH] add remaining time for file --- advcpmv-0.9-9.0.patch | 54 ++++++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/advcpmv-0.9-9.0.patch b/advcpmv-0.9-9.0.patch index f02c22b..5c5071a 100644 --- a/advcpmv-0.9-9.0.patch +++ b/advcpmv-0.9-9.0.patch @@ -1,7 +1,7 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c --- coreutils-9.0/src/copy.c 2021-09-24 13:31:05.000000000 +0200 -+++ coreutils-9.0-patched/src/copy.c 2022-01-10 23:37:17.800794586 +0100 -@@ -129,6 +129,122 @@ ++++ coreutils-9.0-patched/src/copy.c 2022-01-11 20:51:54.334645363 +0100 +@@ -129,6 +129,125 @@ dev_t dev; }; @@ -52,7 +52,10 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c + _cTimeString = (char *) calloc( sizeof(char) * maxneeded, sizeof(char) ); + if ( showall ) + { -+ sprintf(_cTimeString, "%2dh %2dm %2ds", hr, min, (int) sec); ++ if ( seconds < 0 ) ++ sprintf(_cTimeString, "%2ch %2cm %2cs", '0', '0', '?'); ++ else ++ sprintf(_cTimeString, "%2dh %2dm %2ds", hr, min, (int) sec); + } else if ( seconds >= 3600 ) + { + sprintf(_cTimeString, "%2dh %2dm %4.1fs", hr, min, sec); @@ -124,7 +127,7 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c /* Initial size of the cp.dest_info hash table. */ #define DEST_INFO_INITIAL_CAPACITY 61 -@@ -300,9 +416,16 @@ +@@ -300,13 +419,28 @@ static bool sparse_copy (int src_fd, int dest_fd, char *buf, size_t buf_size, size_t hole_size, bool punch_holes, bool allow_reflink, @@ -142,7 +145,19 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c { *last_write_made_hole = false; *total_n_read = 0; -@@ -362,6 +485,93 @@ + ++ /* BEGIN progress mod */ ++ gettimeofday ( & g_oFStartTime, NULL ); ++ g_iFTotalWritten = 0; ++ struct stat st; ++ stat(src_name, &st); ++ g_iFTotalSize = st.st_size/1024; ++ /* END progress mod */ ++ + /* If not looking for holes, use copy_file_range if functional, + but don't use if reflink disallowed as that may be implicit. */ + if ((! hole_size) && allow_reflink && functional_copy_file_range ()) +@@ -362,6 +496,97 @@ while (max_n_read) { @@ -162,6 +177,7 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c + struct timeval cur_time; + gettimeofday ( & cur_time, NULL ); + int cur_size = g_iTotalWritten + *total_n_read / 1024; ++ int cur_fsize = g_iFTotalWritten + *total_n_read / 1024; + int usec_elapsed = cur_time.tv_usec - s_progress->last_time.tv_usec; + double sec_elapsed = ( double ) usec_elapsed / 1000000.f; + sec_elapsed += ( double ) ( cur_time.tv_sec - s_progress->last_time.tv_sec ); @@ -175,8 +191,11 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c + + /* how many time has passed since the start? */ + int isec_elapsed = cur_time.tv_sec - g_oStartTime.tv_sec; ++ int isec_felapsed = cur_time.tv_sec - g_oFStartTime.tv_sec; + int sec_remaining = ( int ) ( ( double ) isec_elapsed / cur_size + * g_iTotalSize ) - isec_elapsed; ++ int sec_fremaining = ( int ) ( ( double ) isec_felapsed / cur_fsize ++ * g_iFTotalSize ) - isec_felapsed; + /* print out */ + + sprintf ( s_progress->cProgressField[1], @@ -187,7 +206,7 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c + + char s_ftime[100] = ""; + if (g_iTotalFiles > 1) -+ s_ftime[0] = '\0'; ++ sprintf ( s_ftime, "(about %s remaining)", format_time(sec_fremaining, true) ); + else + sprintf ( s_ftime, "(about %s remaining)", format_time(sec_remaining, true) ); + @@ -236,7 +255,7 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c ssize_t n_read = read (src_fd, buf, MIN (max_n_read, buf_size)); if (n_read < 0) { -@@ -446,6 +656,14 @@ +@@ -446,6 +671,14 @@ certain files in /proc or /sys with linux kernels. */ } @@ -251,7 +270,7 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c /* Ensure a trailing hole is created, so that subsequent calls of sparse_copy() start at the correct offset. */ if (make_hole && ! create_hole (dest_fd, dst_name, punch_holes, psize)) -@@ -517,8 +735,16 @@ +@@ -517,8 +750,16 @@ lseek_copy (int src_fd, int dest_fd, char *buf, size_t buf_size, size_t hole_size, off_t ext_start, off_t src_total_size, enum Sparse_type sparse_mode, @@ -269,7 +288,7 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c { off_t last_ext_start = 0; off_t last_ext_len = 0; -@@ -590,10 +816,26 @@ +@@ -590,10 +831,26 @@ is conservative and may miss some holes. */ off_t n_read; bool read_hole; @@ -298,7 +317,7 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c return false; dest_pos = ext_start + n_read; -@@ -1374,8 +1616,82 @@ +@@ -1374,8 +1631,82 @@ buf_alloc = xmalloc (buf_size + buf_alignment); buf = ptr_align (buf_alloc, buf_alignment); @@ -381,7 +400,7 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c if (! ( #ifdef SEEK_HOLE scantype == LSEEK_SCANTYPE -@@ -1383,15 +1699,30 @@ +@@ -1383,15 +1714,30 @@ scan_inference.ext_start, src_open_sb.st_size, make_holes ? x->sparse_mode : SPARSE_NEVER, x->reflink_mode != REFLINK_NEVER, @@ -414,7 +433,7 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c { return_val = false; goto close_src_and_dst_desc; -@@ -1402,6 +1733,14 @@ +@@ -1402,6 +1748,14 @@ return_val = false; goto close_src_and_dst_desc; } @@ -431,7 +450,7 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c if (x->preserve_timestamps) diff -aur coreutils-9.0/src/copy.h coreutils-9.0-patched/src/copy.h --- coreutils-9.0/src/copy.h 2021-09-24 13:31:05.000000000 +0200 -+++ coreutils-9.0-patched/src/copy.h 2022-01-10 23:37:17.800794586 +0100 ++++ coreutils-9.0-patched/src/copy.h 2022-01-11 20:51:54.334645363 +0100 @@ -236,6 +236,11 @@ Create destination directories as usual. */ bool symbolic_link; @@ -444,7 +463,7 @@ diff -aur coreutils-9.0/src/copy.h coreutils-9.0-patched/src/copy.h /* If true, do not copy a nondirectory that has an existing destination with the same or newer modification time. */ bool update; -@@ -308,4 +313,19 @@ +@@ -308,4 +313,22 @@ bool chown_failure_ok (struct cp_options const *) _GL_ATTRIBUTE_PURE; mode_t cached_umask (void); @@ -455,10 +474,13 @@ diff -aur coreutils-9.0/src/copy.h coreutils-9.0-patched/src/copy.h +int file_size_format ( char * _cDst, long _lSize, int _iCounter ); + +__attribute__((__common__)) long g_iTotalSize; ++__attribute__((__common__)) long g_iFTotalSize; +__attribute__((__common__)) long g_iTotalWritten; ++__attribute__((__common__)) long g_iFTotalWritten; +__attribute__((__common__)) int g_iFilesCopied; +__attribute__((__common__)) int g_iDirectoriesCopied; +__attribute__((__common__)) struct timeval g_oStartTime; ++__attribute__((__common__)) struct timeval g_oFStartTime; +__attribute__((__common__)) int g_iTotalFiles; +__attribute__((__common__)) bool progress; +/* END progress mod */ @@ -466,7 +488,7 @@ diff -aur coreutils-9.0/src/copy.h coreutils-9.0-patched/src/copy.h #endif diff -aur coreutils-9.0/src/cp.c coreutils-9.0-patched/src/cp.c --- coreutils-9.0/src/cp.c 2021-09-24 13:31:05.000000000 +0200 -+++ coreutils-9.0-patched/src/cp.c 2022-01-10 23:37:17.804794633 +0100 ++++ coreutils-9.0-patched/src/cp.c 2022-01-11 20:51:54.338645406 +0100 @@ -131,6 +131,9 @@ {"symbolic-link", no_argument, NULL, 's'}, {"target-directory", required_argument, NULL, 't'}, @@ -678,7 +700,7 @@ diff -aur coreutils-9.0/src/cp.c coreutils-9.0-patched/src/cp.c version_control_string) diff -aur coreutils-9.0/src/mv.c coreutils-9.0-patched/src/mv.c --- coreutils-9.0/src/mv.c 2021-09-24 13:31:05.000000000 +0200 -+++ coreutils-9.0-patched/src/mv.c 2022-01-10 23:37:17.804794633 +0100 ++++ coreutils-9.0-patched/src/mv.c 2022-01-11 20:51:54.338645406 +0100 @@ -66,6 +66,9 @@ {"target-directory", required_argument, NULL, 't'}, {"update", no_argument, NULL, 'u'},