revert some things for review purposes

This commit is contained in:
Michael Wehr
2022-02-14 21:15:17 +01:00
parent f854b119e9
commit bb5b892ace
2 changed files with 101 additions and 219 deletions

View File

@@ -1,6 +1,6 @@
diff -aur coreutils-8.32/src/copy.c coreutils-8.32-patched/src/copy.c diff -aur coreutils-8.32/src/copy.c coreutils-8.32-patched-nc/src/copy.c
--- coreutils-8.32/src/copy.c 2020-01-01 15:13:12.000000000 +0100 --- coreutils-8.32/src/copy.c 2020-01-01 15:13:12.000000000 +0100
+++ coreutils-8.32-patched/src/copy.c 2022-02-14 21:10:42.216002503 +0100 +++ coreutils-8.32-patched-nc/src/copy.c 2022-02-14 21:14:14.171156659 +0100
@@ -129,6 +129,133 @@ @@ -129,6 +129,133 @@
dev_t dev; dev_t dev;
}; };
@@ -135,21 +135,17 @@ diff -aur coreutils-8.32/src/copy.c coreutils-8.32-patched/src/copy.c
/* Initial size of the cp.dest_info hash table. */ /* Initial size of the cp.dest_info hash table. */
#define DEST_INFO_INITIAL_CAPACITY 61 #define DEST_INFO_INITIAL_CAPACITY 61
@@ -259,17 +386,129 @@ @@ -258,18 +385,124 @@
bytes read. */
static bool static bool
sparse_copy (int src_fd, int dest_fd, char *buf, size_t buf_size, 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,
+ /* BEGIN progress mod */ + size_t hole_size, bool punch_holes, bool move_mode,
+ bool move_mode,
+ /* END progress mod */
char const *src_name, char const *dst_name, char const *src_name, char const *dst_name,
uintmax_t max_n_read, off_t *total_n_read, uintmax_t max_n_read, off_t *total_n_read,
- bool *last_write_made_hole) - bool *last_write_made_hole)
+ bool *last_write_made_hole + bool *last_write_made_hole,
+ /* BEGIN progress mod */ + struct progress_status *s_progress)
+ , struct progress_status *s_progress
+ /* END progress mod */
+ )
{ {
*last_write_made_hole = false; *last_write_made_hole = false;
*total_n_read = 0; *total_n_read = 0;
@@ -266,7 +262,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)); ssize_t n_read = read (src_fd, buf, MIN (max_n_read, buf_size));
if (n_read < 0) if (n_read < 0)
{ {
@@ -354,6 +593,14 @@ @@ -354,6 +587,14 @@
certain files in /proc or /sys with linux kernels. */ certain files in /proc or /sys with linux kernels. */
} }
@@ -281,54 +277,40 @@ diff -aur coreutils-8.32/src/copy.c coreutils-8.32-patched/src/copy.c
/* Ensure a trailing hole is created, so that subsequent /* Ensure a trailing hole is created, so that subsequent
calls of sparse_copy() start at the correct offset. */ calls of sparse_copy() start at the correct offset. */
if (make_hole && ! create_hole (dest_fd, dst_name, punch_holes, psize)) if (make_hole && ! create_hole (dest_fd, dst_name, punch_holes, psize))
@@ -421,8 +668,16 @@ @@ -420,9 +661,11 @@
static bool
extent_copy (int src_fd, int dest_fd, char *buf, size_t buf_size, extent_copy (int src_fd, int dest_fd, char *buf, size_t buf_size,
size_t hole_size, off_t src_total_size, size_t hole_size, off_t src_total_size,
enum Sparse_type sparse_mode, - enum Sparse_type sparse_mode,
+ /* BEGIN progress mod */ + enum Sparse_type sparse_mode, bool move_mode,
+ bool move_mode,
+ /* END progress mod */
char const *src_name, char const *dst_name, char const *src_name, char const *dst_name,
- bool *require_normal_copy) - bool *require_normal_copy)
+ bool *require_normal_copy + bool *require_normal_copy,
+ /* BEGIN progress mod */ + int iCountDown, char ** cProgressField, struct timeval last_time,
+ , int iCountDown, char ** cProgressField, struct timeval last_time, + int last_size, int iBarLength, struct stat src_open_sb)
+ int last_size, int iBarLength, struct stat src_open_sb
+ /* END progress mod */
+ )
{ {
struct extent_scan scan; struct extent_scan scan;
off_t last_ext_start = 0; off_t last_ext_start = 0;
@@ -553,10 +808,26 @@ @@ -553,10 +796,16 @@
last_ext_len = ext_len; last_ext_len = ext_len;
bool read_hole; bool read_hole;
+ /* BEGIN progress mod */
+ struct timeval a; + struct timeval a;
+ struct stat b; + struct stat b;
+ +
+ struct progress_status s_progress={iCountDown, cProgressField, last_time, last_size, iBarLength, src_open_sb}; + struct progress_status s_progress={iCountDown, cProgressField, last_time, last_size, iBarLength, src_open_sb};
+ /* END progress mod */
+ +
+ +
if ( ! sparse_copy (src_fd, dest_fd, buf, buf_size, if ( ! sparse_copy (src_fd, dest_fd, buf, buf_size,
sparse_mode == SPARSE_ALWAYS ? hole_size: 0, 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))
+ true, + true, move_mode, src_name, dst_name, ext_len,
+ /* BEGIN progress mod */ + &n_read, &read_hole, &s_progress))
+ move_mode,
+ /* END progress mod */
+ src_name, dst_name, ext_len, &n_read,
+ &read_hole
+ /* BEGIN progress mod */
+ ,&s_progress
+ /* END progress mod */
+ ))
goto fail; goto fail;
dest_pos = ext_start + n_read; dest_pos = ext_start + n_read;
@@ -1305,6 +1576,75 @@ @@ -1305,6 +1554,75 @@
buf_alloc = xmalloc (buf_size + buf_alignment); buf_alloc = xmalloc (buf_size + buf_alignment);
buf = ptr_align (buf_alloc, buf_alignment); buf = ptr_align (buf_alloc, buf_alignment);
@@ -404,75 +386,56 @@ diff -aur coreutils-8.32/src/copy.c coreutils-8.32-patched/src/copy.c
if (sparse_src) if (sparse_src)
{ {
bool normal_copy_required; bool normal_copy_required;
@@ -1316,7 +1656,15 @@ @@ -1316,7 +1634,9 @@
if (extent_copy (source_desc, dest_desc, buf, buf_size, hole_size, if (extent_copy (source_desc, dest_desc, buf, buf_size, hole_size,
src_open_sb.st_size, src_open_sb.st_size,
make_holes ? x->sparse_mode : SPARSE_NEVER, make_holes ? x->sparse_mode : SPARSE_NEVER,
- src_name, dst_name, &normal_copy_required)) - src_name, dst_name, &normal_copy_required))
+ /* BEGIN progress mod */ + x->move_mode, src_name, dst_name, &normal_copy_required,
+ x->move_mode, + iCountDown, cProgressField, last_time, last_size,
+ /* END progress mod */ + iBarLength, src_open_sb))
+ src_name, dst_name, &normal_copy_required
+ /* BEGIN progress mod */
+ , iCountDown, cProgressField, last_time, last_size,
+ iBarLength, src_open_sb
+ /* END progress mod */
+ ))
goto preserve_metadata; goto preserve_metadata;
if (! normal_copy_required) if (! normal_copy_required)
@@ -1328,11 +1676,24 @@ @@ -1328,11 +1648,14 @@
off_t n_read; off_t n_read;
bool wrote_hole_at_eof; bool wrote_hole_at_eof;
+ +
+ /* BEGIN progress mod */
+ struct progress_status s_progress = { iCountDown, cProgressField, last_time, last_size, iBarLength, src_open_sb}; + struct progress_status s_progress = { iCountDown, cProgressField, last_time, last_size, iBarLength, src_open_sb};
+ /* END progress mod */
+ +
if (! sparse_copy (source_desc, dest_desc, buf, buf_size, if (! sparse_copy (source_desc, dest_desc, buf, buf_size,
make_holes ? hole_size : 0, make_holes ? hole_size : 0,
- x->sparse_mode == SPARSE_ALWAYS, src_name, dst_name, - x->sparse_mode == SPARSE_ALWAYS, src_name, dst_name,
+ x->sparse_mode == SPARSE_ALWAYS, - UINTMAX_MAX, &n_read,
+ /* BEGIN progress mod */
+ x->move_mode,
+ /* END progress mod */
+ src_name, dst_name,
UINTMAX_MAX, &n_read,
- &wrote_hole_at_eof)) - &wrote_hole_at_eof))
+ &wrote_hole_at_eof + x->sparse_mode == SPARSE_ALWAYS, x->move_mode,
+ /* BEGIN progress mod */ + src_name, dst_name, UINTMAX_MAX, &n_read,
+ , &s_progress + &wrote_hole_at_eof, &s_progress))
+ /* END progress mod */
+ ))
{ {
return_val = false; return_val = false;
goto close_src_and_dst_desc; goto close_src_and_dst_desc;
@@ -1343,6 +1704,14 @@ @@ -1343,6 +1666,12 @@
return_val = false; return_val = false;
goto close_src_and_dst_desc; goto close_src_and_dst_desc;
} }
+ /* BEGIN progress mod */
+ if (progress) { + if (progress) {
+ int i; + int i;
+ for ( i = 0; i < 6; i++ ) + for ( i = 0; i < 6; i++ )
+ free ( cProgressField[i] ); + free ( cProgressField[i] );
+ free ( cProgressField ); + free ( cProgressField );
+ } + }
+ /* END progress mod */
} }
preserve_metadata: preserve_metadata:
@@ -1716,15 +2085,19 @@ @@ -1716,15 +2045,15 @@
fprintf (stderr, fprintf (stderr,
(x->move_mode || x->unlink_dest_before_opening (x->move_mode || x->unlink_dest_before_opening
|| x->unlink_dest_after_failed_open) || x->unlink_dest_after_failed_open)
- ? _("%s: replace %s, overriding mode %04lo (%s)? ") - ? _("%s: replace %s, overriding mode %04lo (%s)? ")
- : _("%s: unwritable %s (mode %04lo, %s); try anyway? "), - : _("%s: unwritable %s (mode %04lo, %s); try anyway? "),
+ /* BEGIN progress mod - remove \n\n in string!*/
+ ? _("\n\n%s: replace %s, overriding mode %04lo (%s)? ") + ? _("\n\n%s: replace %s, overriding mode %04lo (%s)? ")
+ : _("\n\n%s: unwritable %s (mode %04lo, %s); try anyway? "), + : _("\n\n%s: unwritable %s (mode %04lo, %s); try anyway? "),
+ /* END progress mod */
program_name, quoteaf (dst_name), program_name, quoteaf (dst_name),
(unsigned long int) (dst_sb->st_mode & CHMOD_MODE_BITS), (unsigned long int) (dst_sb->st_mode & CHMOD_MODE_BITS),
&perms[1]); &perms[1]);
@@ -480,28 +443,24 @@ diff -aur coreutils-8.32/src/copy.c coreutils-8.32-patched/src/copy.c
else else
{ {
- fprintf (stderr, _("%s: overwrite %s? "), - fprintf (stderr, _("%s: overwrite %s? "),
+ /* BEGIN progress mod - remove \n\n in string!*/
+ fprintf (stderr, _("\n\n%s: overwrite %s? "), + fprintf (stderr, _("\n\n%s: overwrite %s? "),
+ /* END progress mod - remove \n\n in string!*/
program_name, quoteaf (dst_name)); program_name, quoteaf (dst_name));
} }
diff -aur coreutils-8.32/src/copy.h coreutils-8.32-patched/src/copy.h diff -aur coreutils-8.32/src/copy.h coreutils-8.32-patched-nc/src/copy.h
--- coreutils-8.32/src/copy.h 2020-01-01 15:13:12.000000000 +0100 --- coreutils-8.32/src/copy.h 2020-01-01 15:13:12.000000000 +0100
+++ coreutils-8.32-patched/src/copy.h 2022-02-14 21:10:42.220002638 +0100 +++ coreutils-8.32-patched-nc/src/copy.h 2022-02-14 21:14:14.175156795 +0100
@@ -234,6 +234,11 @@ @@ -234,6 +234,9 @@
Create destination directories as usual. */ Create destination directories as usual. */
bool symbolic_link; bool symbolic_link;
+ /* BEGIN progress mod */
+ /* If true, draw a nice progress bar on screen */ + /* If true, draw a nice progress bar on screen */
+ bool progress_bar; + bool progress_bar;
+ /* END progress mod */
+ +
/* If true, do not copy a nondirectory that has an existing destination /* If true, do not copy a nondirectory that has an existing destination
with the same or newer modification time. */ with the same or newer modification time. */
bool update; bool update;
@@ -304,4 +309,22 @@ @@ -304,4 +307,22 @@
bool chown_failure_ok (struct cp_options const *) _GL_ATTRIBUTE_PURE; bool chown_failure_ok (struct cp_options const *) _GL_ATTRIBUTE_PURE;
mode_t cached_umask (void); mode_t cached_umask (void);
@@ -524,34 +483,28 @@ diff -aur coreutils-8.32/src/copy.h coreutils-8.32-patched/src/copy.h
+/* END progress mod */ +/* END progress mod */
+ +
#endif #endif
diff -aur coreutils-8.32/src/cp.c coreutils-8.32-patched/src/cp.c diff -aur coreutils-8.32/src/cp.c coreutils-8.32-patched-nc/src/cp.c
--- coreutils-8.32/src/cp.c 2020-01-01 15:13:12.000000000 +0100 --- coreutils-8.32/src/cp.c 2020-01-01 15:13:12.000000000 +0100
+++ coreutils-8.32-patched/src/cp.c 2022-02-14 21:10:42.220002638 +0100 +++ coreutils-8.32-patched-nc/src/cp.c 2022-02-14 21:14:14.175156795 +0100
@@ -131,6 +131,9 @@ @@ -131,6 +131,7 @@
{"symbolic-link", no_argument, NULL, 's'}, {"symbolic-link", no_argument, NULL, 's'},
{"target-directory", required_argument, NULL, 't'}, {"target-directory", required_argument, NULL, 't'},
{"update", no_argument, NULL, 'u'}, {"update", no_argument, NULL, 'u'},
+ /* BEGIN progress mod */
+ {"progress-bar", no_argument, NULL, 'g'}, + {"progress-bar", no_argument, NULL, 'g'},
+ /* END progress mod */
{"verbose", no_argument, NULL, 'v'}, {"verbose", no_argument, NULL, 'v'},
{GETOPT_SELINUX_CONTEXT_OPTION_DECL}, {GETOPT_SELINUX_CONTEXT_OPTION_DECL},
{GETOPT_HELP_OPTION_DECL}, {GETOPT_HELP_OPTION_DECL},
@@ -170,6 +173,13 @@ @@ -170,6 +171,9 @@
-f, --force if an existing destination file cannot be\n\ -f, --force if an existing destination file cannot be\n\
opened, remove it and try again (this option\n\ opened, remove it and try again (this option\n\
is ignored when the -n option is also used)\n\ is ignored when the -n option is also used)\n\
+"), stdout); /* BEGIN progress mod - remove the complete line!*/
+ fputs (_("\
+ -g, --progress-bar add a progress bar.\n\ + -g, --progress-bar add a progress bar.\n\
+ Note that this doesn't work with reflink,\n\ + Note that this doesn't work with reflink,\n\
+ reflink will be automatically disabled\n\ + reflink will be automatically disabled\n\
+"), stdout);
+/* END progress mod - remove the complete line!*/ fputs (_("\
-i, --interactive prompt before overwrite (overrides a previous -n\ -i, --interactive prompt before overwrite (overrides a previous -n\
\n\ \n\
option)\n\ option)\n\
@@ -635,6 +645,84 @@ @@ -635,6 +639,84 @@
die (EXIT_FAILURE, 0, _("target %s is not a directory"), die (EXIT_FAILURE, 0, _("target %s is not a directory"),
quoteaf (file[n_files - 1])); quoteaf (file[n_files - 1]));
} }
@@ -636,7 +589,7 @@ diff -aur coreutils-8.32/src/cp.c coreutils-8.32-patched/src/cp.c
if (target_directory) if (target_directory)
{ {
@@ -777,6 +865,56 @@ @@ -777,6 +859,56 @@
ok = copy (source, new_dest, 0, x, &unused, NULL); ok = copy (source, new_dest, 0, x, &unused, NULL);
} }
@@ -693,55 +646,46 @@ diff -aur coreutils-8.32/src/cp.c coreutils-8.32-patched/src/cp.c
return ok; return ok;
} }
@@ -812,6 +950,11 @@ @@ -812,6 +944,7 @@
x->recursive = false; x->recursive = false;
x->sparse_mode = SPARSE_AUTO; x->sparse_mode = SPARSE_AUTO;
x->symbolic_link = false; x->symbolic_link = false;
+
+ /* BEGIN progress mod */
+ x->progress_bar = false; + x->progress_bar = false;
+ /* END progress mod */
+
x->set_mode = false; x->set_mode = false;
x->mode = 0; x->mode = 0;
@@ -950,7 +1093,8 @@ @@ -950,7 +1083,7 @@
selinux_enabled = (0 < is_selinux_enabled ()); selinux_enabled = (0 < is_selinux_enabled ());
cp_option_init (&x); cp_option_init (&x);
- while ((c = getopt_long (argc, argv, "abdfHilLnprst:uvxPRS:TZ", - while ((c = getopt_long (argc, argv, "abdfHilLnprst:uvxPRS:TZ",
+ /* BEGIN and END progress mod - remove the g in the next line!*/
+ while ((c = getopt_long (argc, argv, "abdfgHilLnprst:uvxPRS:TZ", + while ((c = getopt_long (argc, argv, "abdfgHilLnprst:uvxPRS:TZ",
long_opts, NULL)) long_opts, NULL))
!= -1) != -1)
{ {
@@ -1007,6 +1151,12 @@ @@ -1007,6 +1140,10 @@
x.unlink_dest_after_failed_open = true; x.unlink_dest_after_failed_open = true;
break; break;
+ /* BEGIN progress mod */
+ case 'g': + case 'g':
+ progress = true; + progress = true;
+ break; + break;
+ /* END progress mod */
+ +
case 'H': case 'H':
x.dereference = DEREF_COMMAND_LINE_ARGUMENTS; x.dereference = DEREF_COMMAND_LINE_ARGUMENTS;
break; break;
diff -aur coreutils-8.32/src/mv.c coreutils-8.32-patched/src/mv.c diff -aur coreutils-8.32/src/mv.c coreutils-8.32-patched-nc/src/mv.c
--- coreutils-8.32/src/mv.c 2020-01-01 15:13:12.000000000 +0100 --- coreutils-8.32/src/mv.c 2020-01-01 15:13:12.000000000 +0100
+++ coreutils-8.32-patched/src/mv.c 2022-02-14 21:10:42.220002638 +0100 +++ coreutils-8.32-patched-nc/src/mv.c 2022-02-14 21:14:14.175156795 +0100
@@ -66,6 +66,9 @@ @@ -66,6 +66,7 @@
{"target-directory", required_argument, NULL, 't'}, {"target-directory", required_argument, NULL, 't'},
{"update", no_argument, NULL, 'u'}, {"update", no_argument, NULL, 'u'},
{"verbose", no_argument, NULL, 'v'}, {"verbose", no_argument, NULL, 'v'},
+ /* BEGIN progress mod */
+ {"progress-bar", no_argument, NULL, 'g'}, + {"progress-bar", no_argument, NULL, 'g'},
+ /* END progress mod */
{GETOPT_HELP_OPTION_DECL}, {GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL}, {GETOPT_VERSION_OPTION_DECL},
{NULL, 0, NULL, 0} {NULL, 0, NULL, 0}
@@ -170,8 +173,130 @@ @@ -170,8 +171,130 @@
{ {
bool copy_into_self; bool copy_into_self;
bool rename_succeeded; bool rename_succeeded;
@@ -872,37 +816,30 @@ diff -aur coreutils-8.32/src/mv.c coreutils-8.32-patched/src/mv.c
if (ok) if (ok)
{ {
char const *dir_to_remove; char const *dir_to_remove;
@@ -306,6 +431,11 @@ @@ -306,6 +429,7 @@
\n\ \n\
-b like --backup but does not accept an argument\n\ -b like --backup but does not accept an argument\n\
-f, --force do not prompt before overwriting\n\ -f, --force do not prompt before overwriting\n\
+"), stdout); /* BEGIN progress mod - remove the complete line!*/
+fputs (_("\
+ -g, --progress-bar add progress-bar\n\ + -g, --progress-bar add progress-bar\n\
+"), stdout);
+/* END progress mod - remove the complete line!*/ fputs (_("\
-i, --interactive prompt before overwrite\n\ -i, --interactive prompt before overwrite\n\
-n, --no-clobber do not overwrite an existing file\n\ -n, --no-clobber do not overwrite an existing file\n\
If you specify more than one of -i, -f, -n, only the final one takes effect.\n\ If you specify more than one of -i, -f, -n, only the final one takes effect.\n\
@@ -361,7 +491,8 @@ @@ -361,7 +485,7 @@
/* Try to disable the ability to unlink a directory. */ /* Try to disable the ability to unlink a directory. */
priv_set_remove_linkdir (); priv_set_remove_linkdir ();
- while ((c = getopt_long (argc, argv, "bfint:uvS:TZ", long_options, NULL)) - while ((c = getopt_long (argc, argv, "bfint:uvS:TZ", long_options, NULL))
+ /* BEGIN and END progress mod - remove the g in the next line!*/
+ while ((c = getopt_long (argc, argv, "bfint:uvgS:TZ", long_options, NULL)) + while ((c = getopt_long (argc, argv, "bfint:uvgS:TZ", long_options, NULL))
!= -1) != -1)
{ {
switch (c) switch (c)
@@ -407,6 +538,11 @@ @@ -407,6 +531,9 @@
case 'v': case 'v':
x.verbose = true; x.verbose = true;
break; break;
+ /* BEGIN progress mod */
+ case 'g': + case 'g':
+ progress = true; + progress = true;
+ break; + break;
+ /* END progress mod */
case 'S': case 'S':
make_backups = true; make_backups = true;
backup_suffix = optarg; backup_suffix = optarg;

View File

@@ -1,6 +1,6 @@
diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched-nc/src/copy.c
--- coreutils-9.0/src/copy.c 2021-09-24 13:31:05.000000000 +0200 --- coreutils-9.0/src/copy.c 2021-09-24 13:31:05.000000000 +0200
+++ coreutils-9.0-patched/src/copy.c 2022-02-14 21:04:58.552402945 +0100 +++ coreutils-9.0-patched-nc/src/copy.c 2022-02-14 21:14:14.183157065 +0100
@@ -129,6 +129,133 @@ @@ -129,6 +129,133 @@
dev_t dev; dev_t dev;
}; };
@@ -135,21 +135,17 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c
/* Initial size of the cp.dest_info hash table. */ /* Initial size of the cp.dest_info hash table. */
#define DEST_INFO_INITIAL_CAPACITY 61 #define DEST_INFO_INITIAL_CAPACITY 61
@@ -300,13 +427,28 @@ @@ -299,14 +426,23 @@
bytes read. */
static bool static bool
sparse_copy (int src_fd, int dest_fd, char *buf, size_t buf_size, sparse_copy (int src_fd, int dest_fd, char *buf, size_t buf_size,
size_t hole_size, bool punch_holes, bool allow_reflink, - size_t hole_size, bool punch_holes, bool allow_reflink,
+ /* BEGIN progress mod */ + size_t hole_size, bool punch_holes, bool allow_reflink, bool move_mode,
+ bool move_mode,
+ /* END progress mod */
char const *src_name, char const *dst_name, char const *src_name, char const *dst_name,
uintmax_t max_n_read, off_t *total_n_read, uintmax_t max_n_read, off_t *total_n_read,
- bool *last_write_made_hole) - bool *last_write_made_hole)
+ bool *last_write_made_hole + bool *last_write_made_hole,
+ /* BEGIN progress mod */ + struct progress_status *s_progress)
+ , struct progress_status *s_progress
+ /* END progress mod */
+ )
{ {
*last_write_made_hole = false; *last_write_made_hole = false;
*total_n_read = 0; *total_n_read = 0;
@@ -165,7 +161,7 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c
/* If not looking for holes, use copy_file_range if functional, /* If not looking for holes, use copy_file_range if functional,
but don't use if reflink disallowed as that may be implicit. */ but don't use if reflink disallowed as that may be implicit. */
if ((! hole_size) && allow_reflink && functional_copy_file_range ()) if ((! hole_size) && allow_reflink && functional_copy_file_range ())
@@ -362,6 +504,103 @@ @@ -362,6 +498,103 @@
while (max_n_read) while (max_n_read)
{ {
@@ -269,7 +265,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)); ssize_t n_read = read (src_fd, buf, MIN (max_n_read, buf_size));
if (n_read < 0) if (n_read < 0)
{ {
@@ -446,6 +685,14 @@ @@ -446,6 +679,14 @@
certain files in /proc or /sys with linux kernels. */ certain files in /proc or /sys with linux kernels. */
} }
@@ -284,54 +280,40 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c
/* Ensure a trailing hole is created, so that subsequent /* Ensure a trailing hole is created, so that subsequent
calls of sparse_copy() start at the correct offset. */ calls of sparse_copy() start at the correct offset. */
if (make_hole && ! create_hole (dest_fd, dst_name, punch_holes, psize)) if (make_hole && ! create_hole (dest_fd, dst_name, punch_holes, psize))
@@ -517,8 +764,16 @@ @@ -516,9 +757,11 @@
static bool
lseek_copy (int src_fd, int dest_fd, char *buf, size_t buf_size, 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, size_t hole_size, off_t ext_start, off_t src_total_size,
enum Sparse_type sparse_mode, - enum Sparse_type sparse_mode,
+ /* BEGIN progress mod */ + enum Sparse_type sparse_mode, bool move_mode,
+ bool move_mode,
+ /* END progress mod */
bool allow_reflink, bool allow_reflink,
- char const *src_name, char const *dst_name) - char const *src_name, char const *dst_name)
+ char const *src_name, char const *dst_name + char const *src_name, char const *dst_name,
+ /* BEGIN progress mod */ + int iCountDown, char ** cProgressField, struct timeval last_time,
+ , int iCountDown, char ** cProgressField, struct timeval last_time, + int last_size, int iBarLength, struct stat src_open_sb)
+ int last_size, int iBarLength, struct stat src_open_sb
+ /* END progress mod */
+ )
{ {
off_t last_ext_start = 0; off_t last_ext_start = 0;
off_t last_ext_len = 0; off_t last_ext_len = 0;
@@ -590,10 +845,26 @@ @@ -590,10 +833,16 @@
is conservative and may miss some holes. */ is conservative and may miss some holes. */
off_t n_read; off_t n_read;
bool read_hole; bool read_hole;
+ +
+ /* BEGIN progress mod */
+ struct timeval a; + struct timeval a;
+ struct stat b; + struct stat b;
+ +
+ struct progress_status s_progress={iCountDown, cProgressField, last_time, last_size, iBarLength, src_open_sb}; + struct progress_status s_progress={iCountDown, cProgressField, last_time, last_size, iBarLength, src_open_sb};
+ /* END progress mod */
+ +
if ( ! sparse_copy (src_fd, dest_fd, buf, buf_size, if ( ! sparse_copy (src_fd, dest_fd, buf, buf_size,
sparse_mode == SPARSE_NEVER ? 0 : hole_size, sparse_mode == SPARSE_NEVER ? 0 : hole_size,
- true, allow_reflink, src_name, dst_name, - true, allow_reflink, src_name, dst_name,
- ext_len, &n_read, &read_hole)) - ext_len, &n_read, &read_hole))
+ true, allow_reflink, + true, allow_reflink, move_mode, src_name,
+ /* BEGIN progress mod */ + dst_name, ext_len, &n_read, &read_hole, &s_progress))
+ move_mode,
+ /* END progress mod */
+ src_name, dst_name,
+ ext_len, &n_read, &read_hole
+ /* BEGIN progress mod */
+ , &s_progress
+ /* END progress mod */
+ ))
return false; return false;
dest_pos = ext_start + n_read; dest_pos = ext_start + n_read;
@@ -1374,8 +1645,82 @@ @@ -1374,8 +1623,80 @@
buf_alloc = xmalloc (buf_size + buf_alignment); buf_alloc = xmalloc (buf_size + buf_alignment);
buf = ptr_align (buf_alloc, buf_alignment); buf = ptr_align (buf_alloc, buf_alignment);
@@ -407,47 +389,33 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c
off_t n_read; off_t n_read;
bool wrote_hole_at_eof = false; bool wrote_hole_at_eof = false;
+ +
+ /* BEGIN progress mod */
+ struct progress_status s_progress = { iCountDown, cProgressField, last_time, last_size, iBarLength, src_open_sb}; + struct progress_status s_progress = { iCountDown, cProgressField, last_time, last_size, iBarLength, src_open_sb};
+ /* END progress mod */
+ +
if (! ( if (! (
#ifdef SEEK_HOLE #ifdef SEEK_HOLE
scantype == LSEEK_SCANTYPE scantype == LSEEK_SCANTYPE
@@ -1383,15 +1728,30 @@ @@ -1383,15 +1704,17 @@
scan_inference.ext_start, src_open_sb.st_size, scan_inference.ext_start, src_open_sb.st_size,
make_holes ? x->sparse_mode : SPARSE_NEVER, make_holes ? x->sparse_mode : SPARSE_NEVER,
x->reflink_mode != REFLINK_NEVER, x->reflink_mode != REFLINK_NEVER,
- src_name, dst_name) - src_name, dst_name)
+ /* BEGIN progress mod */ + x->move_mode, src_name, dst_name,
+ x->move_mode, + iCountDown, cProgressField, last_time, last_size,
+ /* END progress mod */ + iBarLength, src_open_sb)
+ src_name, dst_name
+ /* BEGIN progress mod */
+ , iCountDown, cProgressField, last_time, last_size,
+ iBarLength, src_open_sb
+ /* END progress mod */
+ )
: :
#endif #endif
sparse_copy (source_desc, dest_desc, buf, buf_size, sparse_copy (source_desc, dest_desc, buf, buf_size,
make_holes ? hole_size : 0, make_holes ? hole_size : 0,
x->sparse_mode == SPARSE_ALWAYS, x->sparse_mode == SPARSE_ALWAYS,
x->reflink_mode != REFLINK_NEVER, x->reflink_mode != REFLINK_NEVER,
+ /* BEGIN progress mod */ - src_name, dst_name, UINTMAX_MAX, &n_read,
+ x->move_mode,
+ /* END progress mod */
src_name, dst_name, UINTMAX_MAX, &n_read,
- &wrote_hole_at_eof))) - &wrote_hole_at_eof)))
+ &wrote_hole_at_eof + x->move_mode, src_name, dst_name, UINTMAX_MAX,
+ /* BEGIN progress mod */ + &n_read, &wrote_hole_at_eof, &s_progress)))
+ , &s_progress
+ /* END progress mod */
+ )))
{ {
return_val = false; return_val = false;
goto close_src_and_dst_desc; goto close_src_and_dst_desc;
@@ -1402,6 +1762,14 @@ @@ -1402,6 +1725,14 @@
return_val = false; return_val = false;
goto close_src_and_dst_desc; goto close_src_and_dst_desc;
} }
@@ -462,22 +430,20 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c
} }
if (x->preserve_timestamps) if (x->preserve_timestamps)
diff -aur coreutils-9.0/src/copy.h coreutils-9.0-patched/src/copy.h diff -aur coreutils-9.0/src/copy.h coreutils-9.0-patched-nc/src/copy.h
--- coreutils-9.0/src/copy.h 2021-09-24 13:31:05.000000000 +0200 --- coreutils-9.0/src/copy.h 2021-09-24 13:31:05.000000000 +0200
+++ coreutils-9.0-patched/src/copy.h 2022-02-14 21:04:58.564403350 +0100 +++ coreutils-9.0-patched-nc/src/copy.h 2022-02-14 21:14:14.183157065 +0100
@@ -236,6 +236,11 @@ @@ -236,6 +236,9 @@
Create destination directories as usual. */ Create destination directories as usual. */
bool symbolic_link; bool symbolic_link;
+ /* BEGIN progress mod */
+ /* If true, draw a nice progress bar on screen */ + /* If true, draw a nice progress bar on screen */
+ bool progress_bar; + bool progress_bar;
+ /* END progress mod */
+ +
/* If true, do not copy a nondirectory that has an existing destination /* If true, do not copy a nondirectory that has an existing destination
with the same or newer modification time. */ with the same or newer modification time. */
bool update; bool update;
@@ -308,4 +313,22 @@ @@ -308,4 +311,22 @@
bool chown_failure_ok (struct cp_options const *) _GL_ATTRIBUTE_PURE; bool chown_failure_ok (struct cp_options const *) _GL_ATTRIBUTE_PURE;
mode_t cached_umask (void); mode_t cached_umask (void);
@@ -500,34 +466,28 @@ diff -aur coreutils-9.0/src/copy.h coreutils-9.0-patched/src/copy.h
+/* END progress mod */ +/* END progress mod */
+ +
#endif #endif
diff -aur coreutils-9.0/src/cp.c coreutils-9.0-patched/src/cp.c diff -aur coreutils-9.0/src/cp.c coreutils-9.0-patched-nc/src/cp.c
--- coreutils-9.0/src/cp.c 2021-09-24 13:31:05.000000000 +0200 --- coreutils-9.0/src/cp.c 2021-09-24 13:31:05.000000000 +0200
+++ coreutils-9.0-patched/src/cp.c 2022-02-14 21:04:58.572403620 +0100 +++ coreutils-9.0-patched-nc/src/cp.c 2022-02-14 21:14:14.183157065 +0100
@@ -131,6 +131,9 @@ @@ -131,6 +131,7 @@
{"symbolic-link", no_argument, NULL, 's'}, {"symbolic-link", no_argument, NULL, 's'},
{"target-directory", required_argument, NULL, 't'}, {"target-directory", required_argument, NULL, 't'},
{"update", no_argument, NULL, 'u'}, {"update", no_argument, NULL, 'u'},
+ /* BEGIN progress mod */
+ {"progress-bar", no_argument, NULL, 'g'}, + {"progress-bar", no_argument, NULL, 'g'},
+ /* END progress mod */
{"verbose", no_argument, NULL, 'v'}, {"verbose", no_argument, NULL, 'v'},
{GETOPT_SELINUX_CONTEXT_OPTION_DECL}, {GETOPT_SELINUX_CONTEXT_OPTION_DECL},
{GETOPT_HELP_OPTION_DECL}, {GETOPT_HELP_OPTION_DECL},
@@ -170,6 +173,13 @@ @@ -170,6 +171,9 @@
-f, --force if an existing destination file cannot be\n\ -f, --force if an existing destination file cannot be\n\
opened, remove it and try again (this option\n\ opened, remove it and try again (this option\n\
is ignored when the -n option is also used)\n\ is ignored when the -n option is also used)\n\
+"), stdout); /* BEGIN progress mod - remove the complete line!*/
+ fputs (_("\
+ -g, --progress-bar add a progress bar.\n\ + -g, --progress-bar add a progress bar.\n\
+ Note that this doesn't work with reflink,\n\ + Note that this doesn't work with reflink,\n\
+ reflink will be automatically disabled\n\ + reflink will be automatically disabled\n\
+"), stdout);
+/* END progress mod - remove the complete line!*/ fputs (_("\
-i, --interactive prompt before overwrite (overrides a previous -n\ -i, --interactive prompt before overwrite (overrides a previous -n\
\n\ \n\
option)\n\ option)\n\
@@ -634,6 +644,84 @@ @@ -634,6 +638,84 @@
die (EXIT_FAILURE, 0, _("target %s is not a directory"), die (EXIT_FAILURE, 0, _("target %s is not a directory"),
quoteaf (file[n_files - 1])); quoteaf (file[n_files - 1]));
} }
@@ -612,7 +572,7 @@ diff -aur coreutils-9.0/src/cp.c coreutils-9.0-patched/src/cp.c
if (target_directory) if (target_directory)
{ {
@@ -781,6 +869,56 @@ @@ -781,6 +863,56 @@
ok = copy (source, new_dest, 0, x, &unused, NULL); ok = copy (source, new_dest, 0, x, &unused, NULL);
} }
@@ -669,19 +629,17 @@ diff -aur coreutils-9.0/src/cp.c coreutils-9.0-patched/src/cp.c
return ok; return ok;
} }
@@ -816,6 +954,11 @@ @@ -816,6 +948,9 @@
x->recursive = false; x->recursive = false;
x->sparse_mode = SPARSE_AUTO; x->sparse_mode = SPARSE_AUTO;
x->symbolic_link = false; x->symbolic_link = false;
+ +
+ /* BEGIN progress mod */
+ x->progress_bar = false; + x->progress_bar = false;
+ /* END progress mod */
+ +
x->set_mode = false; x->set_mode = false;
x->mode = 0; x->mode = 0;
@@ -954,7 +1097,8 @@ @@ -954,7 +1089,8 @@
selinux_enabled = (0 < is_selinux_enabled ()); selinux_enabled = (0 < is_selinux_enabled ());
cp_option_init (&x); cp_option_init (&x);
@@ -691,45 +649,39 @@ diff -aur coreutils-9.0/src/cp.c coreutils-9.0-patched/src/cp.c
long_opts, NULL)) long_opts, NULL))
!= -1) != -1)
{ {
@@ -1011,6 +1155,12 @@ @@ -1011,6 +1147,10 @@
x.unlink_dest_after_failed_open = true; x.unlink_dest_after_failed_open = true;
break; break;
+ /* BEGIN progress mod */
+ case 'g': + case 'g':
+ progress = true; + progress = true;
+ break; + break;
+ /* END progress mod */
+ +
case 'H': case 'H':
x.dereference = DEREF_COMMAND_LINE_ARGUMENTS; x.dereference = DEREF_COMMAND_LINE_ARGUMENTS;
break; break;
@@ -1171,6 +1321,11 @@ @@ -1171,6 +1311,9 @@
usage (EXIT_FAILURE); usage (EXIT_FAILURE);
} }
+ /* BEGIN progress mod */
+ if (progress) + if (progress)
+ x.reflink_mode = REFLINK_NEVER; + x.reflink_mode = REFLINK_NEVER;
+ /* END progress mod */
+ +
x.backup_type = (make_backups x.backup_type = (make_backups
? xget_version (_("backup type"), ? xget_version (_("backup type"),
version_control_string) version_control_string)
diff -aur coreutils-9.0/src/mv.c coreutils-9.0-patched/src/mv.c diff -aur coreutils-9.0/src/mv.c coreutils-9.0-patched-nc/src/mv.c
--- coreutils-9.0/src/mv.c 2021-09-24 13:31:05.000000000 +0200 --- coreutils-9.0/src/mv.c 2021-09-24 13:31:05.000000000 +0200
+++ coreutils-9.0-patched/src/mv.c 2022-02-14 21:04:58.580403890 +0100 +++ coreutils-9.0-patched-nc/src/mv.c 2022-02-14 21:14:14.183157065 +0100
@@ -66,6 +66,9 @@ @@ -66,6 +66,7 @@
{"target-directory", required_argument, NULL, 't'}, {"target-directory", required_argument, NULL, 't'},
{"update", no_argument, NULL, 'u'}, {"update", no_argument, NULL, 'u'},
{"verbose", no_argument, NULL, 'v'}, {"verbose", no_argument, NULL, 'v'},
+ /* BEGIN progress mod */
+ {"progress-bar", no_argument, NULL, 'g'}, + {"progress-bar", no_argument, NULL, 'g'},
+ /* END progress mod */
{GETOPT_HELP_OPTION_DECL}, {GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL}, {GETOPT_VERSION_OPTION_DECL},
{NULL, 0, NULL, 0} {NULL, 0, NULL, 0}
@@ -170,8 +173,130 @@ @@ -170,8 +171,130 @@
{ {
bool copy_into_self; bool copy_into_self;
bool rename_succeeded; bool rename_succeeded;
@@ -860,37 +812,30 @@ diff -aur coreutils-9.0/src/mv.c coreutils-9.0-patched/src/mv.c
if (ok) if (ok)
{ {
char const *dir_to_remove; char const *dir_to_remove;
@@ -306,6 +431,11 @@ @@ -306,6 +429,7 @@
\n\ \n\
-b like --backup but does not accept an argument\n\ -b like --backup but does not accept an argument\n\
-f, --force do not prompt before overwriting\n\ -f, --force do not prompt before overwriting\n\
+"), stdout); /* BEGIN progress mod - remove the complete line!*/
+fputs (_("\
+ -g, --progress-bar add progress-bar\n\ + -g, --progress-bar add progress-bar\n\
+"), stdout);
+/* END progress mod - remove the complete line!*/ fputs (_("\
-i, --interactive prompt before overwrite\n\ -i, --interactive prompt before overwrite\n\
-n, --no-clobber do not overwrite an existing file\n\ -n, --no-clobber do not overwrite an existing file\n\
If you specify more than one of -i, -f, -n, only the final one takes effect.\n\ If you specify more than one of -i, -f, -n, only the final one takes effect.\n\
@@ -361,7 +491,8 @@ @@ -361,7 +485,7 @@
/* Try to disable the ability to unlink a directory. */ /* Try to disable the ability to unlink a directory. */
priv_set_remove_linkdir (); priv_set_remove_linkdir ();
- while ((c = getopt_long (argc, argv, "bfint:uvS:TZ", long_options, NULL)) - while ((c = getopt_long (argc, argv, "bfint:uvS:TZ", long_options, NULL))
+ /* BEGIN and END progress mod - remove the g in the next line!*/
+ while ((c = getopt_long (argc, argv, "bfint:uvgS:TZ", long_options, NULL)) + while ((c = getopt_long (argc, argv, "bfint:uvgS:TZ", long_options, NULL))
!= -1) != -1)
{ {
switch (c) switch (c)
@@ -407,6 +538,11 @@ @@ -407,6 +531,9 @@
case 'v': case 'v':
x.verbose = true; x.verbose = true;
break; break;
+ /* BEGIN progress mod */
+ case 'g': + case 'g':
+ progress = true; + progress = true;
+ break; + break;
+ /* END progress mod */
case 'S': case 'S':
make_backups = true; make_backups = true;
backup_suffix = optarg; backup_suffix = optarg;