From d336dd4cbeae6c1c3bd621863c9ffe8700a9f0e5 Mon Sep 17 00:00:00 2001 From: Arun Prakash Jana Date: Sun, 25 Oct 2020 12:42:59 +0530 Subject: [PATCH] Indicate copy/move op correctly in progress msg --- advcpmv-0.8-8.32.patch | 64 ++++++++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 27 deletions(-) diff --git a/advcpmv-0.8-8.32.patch b/advcpmv-0.8-8.32.patch index c4dfc9a..6e2c790 100644 --- a/advcpmv-0.8-8.32.patch +++ b/advcpmv-0.8-8.32.patch @@ -1,6 +1,6 @@ diff -aur coreutils-8.32/src/copy.c coreutils-8.32-patched/src/copy.c ---- coreutils-8.32/src/copy.c 2020-01-01 15:13:12.000000000 +0100 -+++ coreutils-8.32-patched/src/copy.c 2020-05-23 13:25:09.286684100 +0200 +--- coreutils-8.32/src/copy.c 2020-01-01 19:43:12.000000000 +0530 ++++ coreutils-8.32-patched/src/copy.c 2020-10-25 12:28:07.178008701 +0530 @@ -129,6 +129,72 @@ dev_t dev; }; @@ -74,8 +74,12 @@ diff -aur coreutils-8.32/src/copy.c coreutils-8.32-patched/src/copy.c /* Initial size of the cp.dest_info hash table. */ #define DEST_INFO_INITIAL_CAPACITY 61 -@@ -261,7 +327,8 @@ - size_t hole_size, bool punch_holes, +@@ -258,10 +324,11 @@ + bytes read. */ + static bool + sparse_copy (int src_fd, int dest_fd, char *buf, size_t buf_size, +- size_t hole_size, bool punch_holes, ++ size_t hole_size, bool punch_holes, bool move_mode, char const *src_name, char const *dst_name, uintmax_t max_n_read, off_t *total_n_read, - bool *last_write_made_hole) @@ -84,7 +88,7 @@ diff -aur coreutils-8.32/src/copy.c coreutils-8.32-patched/src/copy.c { *last_write_made_hole = false; *total_n_read = 0; -@@ -270,6 +337,83 @@ +@@ -270,6 +337,85 @@ while (max_n_read) { @@ -125,7 +129,9 @@ diff -aur coreutils-8.32/src/copy.c coreutils-8.32-patched/src/copy.c + min_remaining -= hours_remaining * 60; + /* print out */ + sprintf ( s_progress->cProgressField[3], -+ "Copying at %s/s (about %uh %um %us remaining)", s_copy_speed, ++ move_mode ++ ? "Moving at %s/s (about %uh %um %us remaining)" ++ : "Copying at %s/s (about %uh %um %us remaining)", s_copy_speed, + hours_remaining, min_remaining, sec_remaining ); + + int fs_len; @@ -168,7 +174,7 @@ diff -aur coreutils-8.32/src/copy.c coreutils-8.32-patched/src/copy.c ssize_t n_read = read (src_fd, buf, MIN (max_n_read, buf_size)); if (n_read < 0) { -@@ -354,6 +498,14 @@ +@@ -354,6 +500,14 @@ certain files in /proc or /sys with linux kernels. */ } @@ -183,9 +189,12 @@ diff -aur coreutils-8.32/src/copy.c coreutils-8.32-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)) -@@ -422,7 +574,9 @@ +@@ -420,9 +574,11 @@ + static bool + extent_copy (int src_fd, int dest_fd, char *buf, size_t buf_size, size_t hole_size, off_t src_total_size, - enum Sparse_type sparse_mode, +- enum Sparse_type sparse_mode, ++ enum Sparse_type sparse_mode, bool move_mode, char const *src_name, char const *dst_name, - bool *require_normal_copy) + bool *require_normal_copy, @@ -194,7 +203,7 @@ diff -aur coreutils-8.32/src/copy.c coreutils-8.32-patched/src/copy.c { struct extent_scan scan; off_t last_ext_start = 0; -@@ -553,10 +707,16 @@ +@@ -553,10 +709,16 @@ last_ext_len = ext_len; bool read_hole; @@ -206,13 +215,14 @@ diff -aur coreutils-8.32/src/copy.c coreutils-8.32-patched/src/copy.c + if ( ! sparse_copy (src_fd, dest_fd, buf, buf_size, sparse_mode == SPARSE_ALWAYS ? hole_size: 0, - true, src_name, dst_name, ext_len, &n_read, +- true, src_name, dst_name, ext_len, &n_read, - &read_hole)) -+ &read_hole,&s_progress)) ++ true, move_mode, src_name, dst_name, ext_len, ++ &n_read, &read_hole,&s_progress)) goto fail; dest_pos = ext_start + n_read; -@@ -1305,6 +1465,70 @@ +@@ -1305,6 +1467,70 @@ buf_alloc = xmalloc (buf_size + buf_alignment); buf = ptr_align (buf_alloc, buf_alignment); @@ -283,32 +293,34 @@ diff -aur coreutils-8.32/src/copy.c coreutils-8.32-patched/src/copy.c if (sparse_src) { bool normal_copy_required; -@@ -1316,7 +1540,9 @@ +@@ -1316,7 +1542,9 @@ if (extent_copy (source_desc, dest_desc, buf, buf_size, hole_size, src_open_sb.st_size, make_holes ? x->sparse_mode : SPARSE_NEVER, - src_name, dst_name, &normal_copy_required)) -+ src_name, dst_name, &normal_copy_required, ++ x->move_mode, src_name, dst_name, &normal_copy_required, + iCountDown, cProgressField, last_time, last_size, + iBarLength, src_open_sb)) goto preserve_metadata; if (! normal_copy_required) -@@ -1328,11 +1554,12 @@ +@@ -1328,11 +1556,12 @@ off_t n_read; bool wrote_hole_at_eof; + struct progress_status s_progress = { iCountDown, cProgressField, last_time, last_size, iBarLength, src_open_sb}; if (! sparse_copy (source_desc, dest_desc, buf, buf_size, make_holes ? hole_size : 0, - x->sparse_mode == SPARSE_ALWAYS, src_name, dst_name, - UINTMAX_MAX, &n_read, +- x->sparse_mode == SPARSE_ALWAYS, src_name, dst_name, +- UINTMAX_MAX, &n_read, - &wrote_hole_at_eof)) ++ x->sparse_mode == SPARSE_ALWAYS, x->move_mode, ++ src_name, dst_name, UINTMAX_MAX, &n_read, + &wrote_hole_at_eof, &s_progress)) { return_val = false; goto close_src_and_dst_desc; -@@ -1343,6 +1570,14 @@ +@@ -1343,6 +1572,14 @@ return_val = false; goto close_src_and_dst_desc; } @@ -323,10 +335,9 @@ diff -aur coreutils-8.32/src/copy.c coreutils-8.32-patched/src/copy.c } preserve_metadata: -Only in coreutils-8.32-patched/src: copy.c.orig diff -aur coreutils-8.32/src/copy.h coreutils-8.32-patched/src/copy.h ---- coreutils-8.32/src/copy.h 2020-01-01 15:13:12.000000000 +0100 -+++ coreutils-8.32-patched/src/copy.h 2020-05-23 13:25:09.286684100 +0200 +--- coreutils-8.32/src/copy.h 2020-01-01 19:43:12.000000000 +0530 ++++ coreutils-8.32-patched/src/copy.h 2020-10-25 12:19:01.488366069 +0530 @@ -234,6 +234,9 @@ Create destination directories as usual. */ bool symbolic_link; @@ -353,10 +364,9 @@ diff -aur coreutils-8.32/src/copy.h coreutils-8.32-patched/src/copy.h +/* END OF PROGRESS MOD */ + #endif -Only in coreutils-8.32-patched/src: copy.h.orig diff -aur coreutils-8.32/src/cp.c coreutils-8.32-patched/src/cp.c ---- coreutils-8.32/src/cp.c 2020-01-01 15:13:12.000000000 +0100 -+++ coreutils-8.32-patched/src/cp.c 2020-05-23 13:25:09.286684100 +0200 +--- coreutils-8.32/src/cp.c 2020-01-01 19:43:12.000000000 +0530 ++++ coreutils-8.32-patched/src/cp.c 2020-10-25 12:19:01.488366069 +0530 @@ -131,6 +131,7 @@ {"symbolic-link", no_argument, NULL, 's'}, {"target-directory", required_argument, NULL, 't'}, @@ -520,8 +530,8 @@ diff -aur coreutils-8.32/src/cp.c coreutils-8.32-patched/src/cp.c x.dereference = DEREF_COMMAND_LINE_ARGUMENTS; break; diff -aur coreutils-8.32/src/mv.c coreutils-8.32-patched/src/mv.c ---- coreutils-8.32/src/mv.c 2020-01-01 15:13:12.000000000 +0100 -+++ coreutils-8.32-patched/src/mv.c 2020-05-23 13:25:09.286684100 +0200 +--- coreutils-8.32/src/mv.c 2020-01-01 19:43:12.000000000 +0530 ++++ coreutils-8.32-patched/src/mv.c 2020-10-25 12:19:01.488366069 +0530 @@ -66,6 +66,7 @@ {"target-directory", required_argument, NULL, 't'}, {"update", no_argument, NULL, 'u'},