mirror of
https://github.com/jarun/advcpmv.git
synced 2026-02-01 13:17:41 +01:00
add more comments to identify all progress mod changes
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
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 2021-12-23 09:03:07.290374485 +0100
|
||||
+++ coreutils-9.0-patched/src/copy.c 2021-12-23 11:35:19.632502471 +0100
|
||||
@@ -129,6 +129,101 @@
|
||||
dev_t dev;
|
||||
};
|
||||
@@ -103,21 +103,25 @@ 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
|
||||
|
||||
@@ -299,10 +394,11 @@
|
||||
bytes read. */
|
||||
@@ -300,9 +395,16 @@
|
||||
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,
|
||||
+ size_t hole_size, bool punch_holes, bool allow_reflink, bool move_mode,
|
||||
size_t hole_size, bool punch_holes, bool allow_reflink,
|
||||
+ /* BEGIN progress mod */
|
||||
+ bool move_mode,
|
||||
+ /* END progress mod */
|
||||
char const *src_name, char const *dst_name,
|
||||
uintmax_t max_n_read, off_t *total_n_read,
|
||||
- bool *last_write_made_hole)
|
||||
+ bool *last_write_made_hole,
|
||||
+ struct progress_status *s_progress)
|
||||
+ bool *last_write_made_hole
|
||||
+ /* BEGIN progress mod */
|
||||
+ , struct progress_status *s_progress
|
||||
+ /* END progress mod */
|
||||
+ )
|
||||
{
|
||||
*last_write_made_hole = false;
|
||||
*total_n_read = 0;
|
||||
@@ -362,6 +458,85 @@
|
||||
@@ -362,6 +464,85 @@
|
||||
|
||||
while (max_n_read)
|
||||
{
|
||||
@@ -203,7 +207,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 +621,14 @@
|
||||
@@ -446,6 +627,14 @@
|
||||
certain files in /proc or /sys with linux kernels. */
|
||||
}
|
||||
|
||||
@@ -218,40 +222,54 @@ 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))
|
||||
@@ -516,9 +699,11 @@
|
||||
static bool
|
||||
@@ -517,8 +706,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,
|
||||
+ enum Sparse_type sparse_mode, bool move_mode,
|
||||
enum Sparse_type sparse_mode,
|
||||
+ /* BEGIN progress mod */
|
||||
+ bool move_mode,
|
||||
+ /* END progress mod */
|
||||
bool allow_reflink,
|
||||
- char const *src_name, char const *dst_name)
|
||||
+ char const *src_name, char const *dst_name,
|
||||
+ int iCountDown, char ** cProgressField, struct timeval last_time,
|
||||
+ int last_size, int iBarLength, struct stat src_open_sb)
|
||||
+ char const *src_name, char const *dst_name
|
||||
+ /* BEGIN progress mod */
|
||||
+ , int iCountDown, char ** cProgressField, struct timeval last_time,
|
||||
+ int last_size, int iBarLength, struct stat src_open_sb
|
||||
+ /* END progress mod */
|
||||
+ )
|
||||
{
|
||||
off_t last_ext_start = 0;
|
||||
off_t last_ext_len = 0;
|
||||
@@ -590,10 +775,16 @@
|
||||
@@ -590,10 +787,26 @@
|
||||
is conservative and may miss some holes. */
|
||||
off_t n_read;
|
||||
bool read_hole;
|
||||
+
|
||||
+ /* BEGIN progress mod */
|
||||
+ struct timeval a;
|
||||
+ struct stat b;
|
||||
+
|
||||
+ 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,
|
||||
sparse_mode == SPARSE_NEVER ? 0 : hole_size,
|
||||
- true, allow_reflink, src_name, dst_name,
|
||||
- ext_len, &n_read, &read_hole))
|
||||
+ true, allow_reflink, move_mode, src_name,
|
||||
+ dst_name, ext_len, &n_read, &read_hole, &s_progress))
|
||||
+ true, allow_reflink,
|
||||
+ /* BEGIN progress mod */
|
||||
+ 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;
|
||||
|
||||
dest_pos = ext_start + n_read;
|
||||
@@ -1374,8 +1565,74 @@
|
||||
@@ -1374,8 +1587,78 @@
|
||||
buf_alloc = xmalloc (buf_size + buf_alignment);
|
||||
buf = ptr_align (buf_alloc, buf_alignment);
|
||||
|
||||
@@ -322,32 +340,48 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c
|
||||
+
|
||||
off_t n_read;
|
||||
bool wrote_hole_at_eof = false;
|
||||
+
|
||||
+ /* BEGIN progress mod */
|
||||
+ struct progress_status s_progress = { iCountDown, cProgressField, last_time, last_size, iBarLength, src_open_sb};
|
||||
+ /* END progress mod */
|
||||
+
|
||||
if (! (
|
||||
#ifdef SEEK_HOLE
|
||||
scantype == LSEEK_SCANTYPE
|
||||
@@ -1383,15 +1640,17 @@
|
||||
@@ -1383,15 +1666,30 @@
|
||||
scan_inference.ext_start, src_open_sb.st_size,
|
||||
make_holes ? x->sparse_mode : SPARSE_NEVER,
|
||||
x->reflink_mode != REFLINK_NEVER,
|
||||
- src_name, dst_name)
|
||||
+ x->move_mode, src_name, dst_name,
|
||||
+ iCountDown, cProgressField, last_time, last_size,
|
||||
+ iBarLength, src_open_sb)
|
||||
+ /* BEGIN progress mod */
|
||||
+ x->move_mode,
|
||||
+ /* END progress mod */
|
||||
+ src_name, dst_name
|
||||
+ /* BEGIN progress mod */
|
||||
+ , iCountDown, cProgressField, last_time, last_size,
|
||||
+ iBarLength, src_open_sb
|
||||
+ /* END progress mod */
|
||||
+ )
|
||||
:
|
||||
#endif
|
||||
sparse_copy (source_desc, dest_desc, buf, buf_size,
|
||||
make_holes ? hole_size : 0,
|
||||
x->sparse_mode == SPARSE_ALWAYS,
|
||||
x->reflink_mode != REFLINK_NEVER,
|
||||
- src_name, dst_name, 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)))
|
||||
+ x->move_mode, src_name, dst_name, UINTMAX_MAX,
|
||||
+ &n_read, &wrote_hole_at_eof, &s_progress)))
|
||||
+ &wrote_hole_at_eof
|
||||
+ /* BEGIN progress mod */
|
||||
+ , &s_progress
|
||||
+ /* END progress mod */
|
||||
+ )))
|
||||
{
|
||||
return_val = false;
|
||||
goto close_src_and_dst_desc;
|
||||
@@ -1402,6 +1661,14 @@
|
||||
@@ -1402,6 +1700,14 @@
|
||||
return_val = false;
|
||||
goto close_src_and_dst_desc;
|
||||
}
|
||||
@@ -364,18 +398,20 @@ 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 2021-12-22 22:30:16.072134557 +0100
|
||||
@@ -236,6 +236,9 @@
|
||||
+++ coreutils-9.0-patched/src/copy.h 2021-12-23 09:37:38.015722020 +0100
|
||||
@@ -236,6 +236,11 @@
|
||||
Create destination directories as usual. */
|
||||
bool symbolic_link;
|
||||
|
||||
+ /* BEGIN progress mod */
|
||||
+ /* If true, draw a nice progress bar on screen */
|
||||
+ bool progress_bar;
|
||||
+ /* END progress mod */
|
||||
+
|
||||
/* If true, do not copy a nondirectory that has an existing destination
|
||||
with the same or newer modification time. */
|
||||
bool update;
|
||||
@@ -308,4 +311,18 @@
|
||||
@@ -308,4 +313,18 @@
|
||||
bool chown_failure_ok (struct cp_options const *) _GL_ATTRIBUTE_PURE;
|
||||
mode_t cached_umask (void);
|
||||
|
||||
@@ -396,26 +432,32 @@ 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 2021-12-22 18:28:14.781215839 +0100
|
||||
@@ -131,6 +131,7 @@
|
||||
+++ coreutils-9.0-patched/src/cp.c 2021-12-23 11:44:06.012603217 +0100
|
||||
@@ -131,6 +131,9 @@
|
||||
{"symbolic-link", no_argument, NULL, 's'},
|
||||
{"target-directory", required_argument, NULL, 't'},
|
||||
{"update", no_argument, NULL, 'u'},
|
||||
+ /* BEGIN progress mod */
|
||||
+ {"progress-bar", no_argument, NULL, 'g'},
|
||||
+ /* END progress mod */
|
||||
{"verbose", no_argument, NULL, 'v'},
|
||||
{GETOPT_SELINUX_CONTEXT_OPTION_DECL},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
@@ -170,6 +171,9 @@
|
||||
@@ -170,6 +173,13 @@
|
||||
-f, --force if an existing destination file cannot be\n\
|
||||
opened, remove it and try again (this option\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\
|
||||
+ Note that this doesn't work with reflink,\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\
|
||||
\n\
|
||||
option)\n\
|
||||
@@ -634,6 +638,73 @@
|
||||
@@ -634,6 +644,73 @@
|
||||
die (EXIT_FAILURE, 0, _("target %s is not a directory"),
|
||||
quoteaf (file[n_files - 1]));
|
||||
}
|
||||
@@ -489,7 +531,7 @@ diff -aur coreutils-9.0/src/cp.c coreutils-9.0-patched/src/cp.c
|
||||
|
||||
if (target_directory)
|
||||
{
|
||||
@@ -781,6 +852,46 @@
|
||||
@@ -781,6 +858,46 @@
|
||||
ok = copy (source, new_dest, 0, x, &unused, NULL);
|
||||
}
|
||||
|
||||
@@ -536,7 +578,7 @@ diff -aur coreutils-9.0/src/cp.c coreutils-9.0-patched/src/cp.c
|
||||
return ok;
|
||||
}
|
||||
|
||||
@@ -816,6 +927,7 @@
|
||||
@@ -816,6 +933,7 @@
|
||||
x->recursive = false;
|
||||
x->sparse_mode = SPARSE_AUTO;
|
||||
x->symbolic_link = false;
|
||||
@@ -544,57 +586,62 @@ diff -aur coreutils-9.0/src/cp.c coreutils-9.0-patched/src/cp.c
|
||||
x->set_mode = false;
|
||||
x->mode = 0;
|
||||
|
||||
@@ -954,7 +1066,7 @@
|
||||
@@ -954,7 +1072,8 @@
|
||||
selinux_enabled = (0 < is_selinux_enabled ());
|
||||
cp_option_init (&x);
|
||||
|
||||
- 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",
|
||||
long_opts, NULL))
|
||||
!= -1)
|
||||
{
|
||||
@@ -1011,6 +1123,10 @@
|
||||
@@ -1011,6 +1130,12 @@
|
||||
x.unlink_dest_after_failed_open = true;
|
||||
break;
|
||||
|
||||
+ /* BEGIN progress mod */
|
||||
+ case 'g':
|
||||
+ progress = true;
|
||||
+ break;
|
||||
+ /* END progress mod */
|
||||
+
|
||||
case 'H':
|
||||
x.dereference = DEREF_COMMAND_LINE_ARGUMENTS;
|
||||
break;
|
||||
@@ -1171,6 +1287,9 @@
|
||||
@@ -1171,6 +1296,11 @@
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
+ /* BEGIN progress mod */
|
||||
+ if (progress)
|
||||
+ x.reflink_mode = REFLINK_NEVER;
|
||||
+ /* END progress mod */
|
||||
+
|
||||
x.backup_type = (make_backups
|
||||
? xget_version (_("backup type"),
|
||||
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 2021-12-22 23:27:30.329010117 +0100
|
||||
@@ -66,6 +66,7 @@
|
||||
+++ coreutils-9.0-patched/src/mv.c 2021-12-23 11:57:51.221688967 +0100
|
||||
@@ -66,6 +66,9 @@
|
||||
{"target-directory", required_argument, NULL, 't'},
|
||||
{"update", no_argument, NULL, 'u'},
|
||||
{"verbose", no_argument, NULL, 'v'},
|
||||
+ /* BEGIN progress mod */
|
||||
+ {"progress-bar", no_argument, NULL, 'g'},
|
||||
+ /* END progress mod */
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
@@ -168,10 +169,108 @@
|
||||
static bool
|
||||
do_move (char const *source, char const *dest, const struct cp_options *x)
|
||||
@@ -170,8 +173,106 @@
|
||||
{
|
||||
+ struct timeval start_time;
|
||||
+
|
||||
bool copy_into_self;
|
||||
bool rename_succeeded;
|
||||
+
|
||||
+ /* BEGIN progress mod */
|
||||
+ struct timeval start_time;
|
||||
+
|
||||
+ if(progress && x->rename_errno != 0) {
|
||||
+ if (g_iTotalSize == 0)
|
||||
+ g_iTotalSize = 0;
|
||||
@@ -694,30 +741,37 @@ diff -aur coreutils-9.0/src/mv.c coreutils-9.0-patched/src/mv.c
|
||||
if (ok)
|
||||
{
|
||||
char const *dir_to_remove;
|
||||
@@ -306,6 +405,7 @@
|
||||
@@ -306,6 +407,11 @@
|
||||
\n\
|
||||
-b like --backup but does not accept an argument\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\
|
||||
+"), stdout);
|
||||
+/* END progress mod - remove the complete line!*/ fputs (_("\
|
||||
-i, --interactive prompt before overwrite\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\
|
||||
@@ -361,7 +461,7 @@
|
||||
@@ -361,7 +467,8 @@
|
||||
/* Try to disable the ability to unlink a directory. */
|
||||
priv_set_remove_linkdir ();
|
||||
|
||||
- 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))
|
||||
!= -1)
|
||||
{
|
||||
switch (c)
|
||||
@@ -407,6 +507,9 @@
|
||||
@@ -407,6 +514,11 @@
|
||||
case 'v':
|
||||
x.verbose = true;
|
||||
break;
|
||||
+ /* BEGIN progress mod */
|
||||
+ case 'g':
|
||||
+ progress = true;
|
||||
+ break;
|
||||
+ /* END progress mod */
|
||||
case 'S':
|
||||
make_backups = true;
|
||||
backup_suffix = optarg;
|
||||
|
||||
Reference in New Issue
Block a user