mirror of
https://github.com/jarun/advcpmv.git
synced 2026-02-01 13:17:41 +01:00
Merge pull request #14 from SlrG/fixandimprovements
Fix and Improvements
This commit is contained in:
@@ -1,10 +1,11 @@
|
|||||||
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 2021-08-11 19:48:19.008225844 +0200
|
+++ coreutils-8.32-patched-nc/src/copy.c 2022-02-14 21:14:14.171156659 +0100
|
||||||
@@ -129,6 +129,72 @@
|
@@ -129,6 +129,133 @@
|
||||||
dev_t dev;
|
dev_t dev;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
+/* BEGIN progress mod */
|
||||||
+struct progress_status {
|
+struct progress_status {
|
||||||
+ int iCountDown;
|
+ int iCountDown;
|
||||||
+ char ** cProgressField;
|
+ char ** cProgressField;
|
||||||
@@ -13,7 +14,69 @@ diff -aur coreutils-8.32/src/copy.c coreutils-8.32-patched/src/copy.c
|
|||||||
+ struct stat src_open_sb;
|
+ struct stat src_open_sb;
|
||||||
+};
|
+};
|
||||||
+
|
+
|
||||||
+/* Begin progress Mod*/
|
+FILE * spawn( const char *cmd, char *const argv[] )
|
||||||
|
+{
|
||||||
|
+ FILE *ret = NULL;
|
||||||
|
+ int pfd_read[2];
|
||||||
|
+ pid_t pid;
|
||||||
|
+
|
||||||
|
+ if (cmd == NULL || argv == NULL)
|
||||||
|
+ return ret;
|
||||||
|
+
|
||||||
|
+ if (pipe(pfd_read) < 0) {
|
||||||
|
+ error(0, errno, "pipe: %s", cmd);
|
||||||
|
+ return ret;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if ((pid = fork()) == 0) {
|
||||||
|
+ int err = dup2(pfd_read[1], 1) < 0;
|
||||||
|
+ close(pfd_read[0]);
|
||||||
|
+ close(pfd_read[1]);
|
||||||
|
+
|
||||||
|
+ if (err)
|
||||||
|
+ error(EXIT_FAILURE, errno, "dup2: %s", cmd);
|
||||||
|
+ execvp(cmd, argv);
|
||||||
|
+ error(EXIT_FAILURE, errno, "exec: %s", cmd);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ close(pfd_read[1]);
|
||||||
|
+
|
||||||
|
+ if (pid < 0) {
|
||||||
|
+ close(pfd_read[0]);
|
||||||
|
+ error(0, errno, "fork: %s", cmd);
|
||||||
|
+ return ret;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ ret = fdopen(pfd_read[0], "r");
|
||||||
|
+ return ret;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void format_time ( char * _cDest, double seconds, bool showall )
|
||||||
|
+{
|
||||||
|
+ // hours
|
||||||
|
+ int hr = ( (int) seconds / (60 * 60)) % 24;
|
||||||
|
+ // minutes
|
||||||
|
+ int min = ( (int) seconds / 60) % 60;
|
||||||
|
+ // seconds
|
||||||
|
+ double sec = seconds - (hr * (60 * 60)) - (min * 60);
|
||||||
|
+ if ( showall )
|
||||||
|
+ {
|
||||||
|
+ if ( seconds < 0 )
|
||||||
|
+ sprintf(_cDest, "%2ch %2cm %2cs", '0', '0', '?');
|
||||||
|
+ else
|
||||||
|
+ sprintf(_cDest, "%2dh %2dm %2ds", hr, min, (int) sec);
|
||||||
|
+ } else if ( seconds >= 3600 )
|
||||||
|
+ {
|
||||||
|
+ sprintf(_cDest, "%2dh %2dm %4.1fs", hr, min, sec);
|
||||||
|
+ } else if ( seconds >= 60 )
|
||||||
|
+ {
|
||||||
|
+ sprintf(_cDest, "%2dm %4.1fs", min, sec);
|
||||||
|
+ } else
|
||||||
|
+ {
|
||||||
|
+ sprintf(_cDest, "%4.1fs", sec);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
+static void file_progress_bar ( char * _cDest, int _iBarLength, long _lProgress, long _lTotal )
|
+static void file_progress_bar ( char * _cDest, int _iBarLength, long _lProgress, long _lTotal )
|
||||||
+{
|
+{
|
||||||
+ double dPercent = (double) _lProgress / (double) _lTotal * 100.f;
|
+ double dPercent = (double) _lProgress / (double) _lTotal * 100.f;
|
||||||
@@ -68,13 +131,11 @@ diff -aur coreutils-8.32/src/copy.c coreutils-8.32-patched/src/copy.c
|
|||||||
+ return sprintf ( _cDst, "%5.1f %s", dSize, sUnit );
|
+ return sprintf ( _cDst, "%5.1f %s", dSize, sUnit );
|
||||||
+}
|
+}
|
||||||
+/* END progress mod */
|
+/* END progress mod */
|
||||||
+
|
|
||||||
+
|
|
||||||
+
|
+
|
||||||
/* 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
|
||||||
|
|
||||||
@@ -258,10 +324,11 @@
|
@@ -258,18 +385,124 @@
|
||||||
bytes read. */
|
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,
|
||||||
@@ -88,13 +149,22 @@ diff -aur coreutils-8.32/src/copy.c coreutils-8.32-patched/src/copy.c
|
|||||||
{
|
{
|
||||||
*last_write_made_hole = false;
|
*last_write_made_hole = false;
|
||||||
*total_n_read = 0;
|
*total_n_read = 0;
|
||||||
@@ -270,6 +337,85 @@
|
bool make_hole = false;
|
||||||
|
off_t psize = 0;
|
||||||
|
|
||||||
|
+ /* 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 */
|
||||||
|
+
|
||||||
while (max_n_read)
|
while (max_n_read)
|
||||||
{
|
{
|
||||||
+
|
+
|
||||||
|
+ /* BEGIN progress mod */
|
||||||
+ if (progress) {
|
+ if (progress) {
|
||||||
+ /* BEGIN progress mod */
|
|
||||||
+ /* update countdown */
|
+ /* update countdown */
|
||||||
+ s_progress->iCountDown--;
|
+ s_progress->iCountDown--;
|
||||||
+ char * sProgressBar = s_progress->cProgressField[5];
|
+ char * sProgressBar = s_progress->cProgressField[5];
|
||||||
@@ -108,6 +178,7 @@ diff -aur coreutils-8.32/src/copy.c coreutils-8.32-patched/src/copy.c
|
|||||||
+ struct timeval cur_time;
|
+ struct timeval cur_time;
|
||||||
+ gettimeofday ( & cur_time, NULL );
|
+ gettimeofday ( & cur_time, NULL );
|
||||||
+ int cur_size = g_iTotalWritten + *total_n_read / 1024;
|
+ 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;
|
+ int usec_elapsed = cur_time.tv_usec - s_progress->last_time.tv_usec;
|
||||||
+ double sec_elapsed = ( double ) usec_elapsed / 1000000.f;
|
+ double sec_elapsed = ( double ) usec_elapsed / 1000000.f;
|
||||||
+ sec_elapsed += ( double ) ( cur_time.tv_sec - s_progress->last_time.tv_sec );
|
+ sec_elapsed += ( double ) ( cur_time.tv_sec - s_progress->last_time.tv_sec );
|
||||||
@@ -121,18 +192,35 @@ diff -aur coreutils-8.32/src/copy.c coreutils-8.32-patched/src/copy.c
|
|||||||
+
|
+
|
||||||
+ /* how many time has passed since the start? */
|
+ /* how many time has passed since the start? */
|
||||||
+ int isec_elapsed = cur_time.tv_sec - g_oStartTime.tv_sec;
|
+ 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
|
+ int sec_remaining = ( int ) ( ( double ) isec_elapsed / cur_size
|
||||||
+ * g_iTotalSize ) - isec_elapsed;
|
+ * g_iTotalSize ) - isec_elapsed;
|
||||||
+ int min_remaining = sec_remaining / 60;
|
+ int sec_fremaining = ( int ) ( ( double ) isec_felapsed / cur_fsize
|
||||||
+ sec_remaining -= min_remaining * 60;
|
+ * g_iFTotalSize ) - isec_felapsed;
|
||||||
+ int hours_remaining = min_remaining / 60;
|
|
||||||
+ min_remaining -= hours_remaining * 60;
|
|
||||||
+ /* print out */
|
+ /* print out */
|
||||||
|
+
|
||||||
|
+ char f_ttime[20];
|
||||||
|
+ char f_ftime[20];
|
||||||
|
+ format_time(f_ttime, sec_remaining, true);
|
||||||
|
+ format_time(f_ftime, sec_fremaining, true);
|
||||||
|
+
|
||||||
|
+ sprintf ( s_progress->cProgressField[1],
|
||||||
|
+ move_mode
|
||||||
|
+ ? "%d of %d files moved (about %s remaining) "
|
||||||
|
+ : "%d of %d files copied (about %s remaining) ",
|
||||||
|
+ g_iFilesCopied, g_iTotalFiles, f_ttime );
|
||||||
|
+
|
||||||
|
+ char s_ftime[40] = "";
|
||||||
|
+
|
||||||
|
+ if (g_iTotalFiles > 1)
|
||||||
|
+ sprintf ( s_ftime, "(about %s remaining)", f_ftime );
|
||||||
|
+ else
|
||||||
|
+ sprintf ( s_ftime, "(about %s remaining)", f_ttime );
|
||||||
|
+
|
||||||
+ sprintf ( s_progress->cProgressField[3],
|
+ sprintf ( s_progress->cProgressField[3],
|
||||||
+ move_mode
|
+ move_mode
|
||||||
+ ? "Moving at %s/s (about %uh %um %us remaining)"
|
+ ? "moving at %s/s %s"
|
||||||
+ : "Copying at %s/s (about %uh %um %us remaining)", s_copy_speed,
|
+ : "copying at %s/s %s", s_copy_speed, s_ftime );
|
||||||
+ hours_remaining, min_remaining, sec_remaining );
|
|
||||||
+
|
+
|
||||||
+ int fs_len;
|
+ int fs_len;
|
||||||
+ if ( g_iTotalFiles > 1 )
|
+ if ( g_iTotalFiles > 1 )
|
||||||
@@ -168,13 +256,13 @@ diff -aur coreutils-8.32/src/copy.c coreutils-8.32-patched/src/copy.c
|
|||||||
+ printf ( "\r\033[3A" );
|
+ printf ( "\r\033[3A" );
|
||||||
+ fflush ( stdout );
|
+ fflush ( stdout );
|
||||||
+ }
|
+ }
|
||||||
+ /* END progress mod */
|
|
||||||
+ }
|
+ }
|
||||||
|
+ /* END progress mod */
|
||||||
+
|
+
|
||||||
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 +500,14 @@
|
@@ -354,6 +587,14 @@
|
||||||
certain files in /proc or /sys with linux kernels. */
|
certain files in /proc or /sys with linux kernels. */
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,7 +277,7 @@ 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))
|
||||||
@@ -420,9 +574,11 @@
|
@@ -420,9 +661,11 @@
|
||||||
static bool
|
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,
|
||||||
@@ -203,7 +291,7 @@ diff -aur coreutils-8.32/src/copy.c coreutils-8.32-patched/src/copy.c
|
|||||||
{
|
{
|
||||||
struct extent_scan scan;
|
struct extent_scan scan;
|
||||||
off_t last_ext_start = 0;
|
off_t last_ext_start = 0;
|
||||||
@@ -553,10 +709,16 @@
|
@@ -553,10 +796,16 @@
|
||||||
last_ext_len = ext_len;
|
last_ext_len = ext_len;
|
||||||
bool read_hole;
|
bool read_hole;
|
||||||
|
|
||||||
@@ -218,11 +306,11 @@ diff -aur coreutils-8.32/src/copy.c coreutils-8.32-patched/src/copy.c
|
|||||||
- true, src_name, dst_name, ext_len, &n_read,
|
- true, src_name, dst_name, ext_len, &n_read,
|
||||||
- &read_hole))
|
- &read_hole))
|
||||||
+ true, move_mode, src_name, dst_name, ext_len,
|
+ true, move_mode, src_name, dst_name, ext_len,
|
||||||
+ &n_read, &read_hole,&s_progress))
|
+ &n_read, &read_hole, &s_progress))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
dest_pos = ext_start + n_read;
|
dest_pos = ext_start + n_read;
|
||||||
@@ -1305,6 +1467,71 @@
|
@@ -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);
|
||||||
|
|
||||||
@@ -261,7 +349,11 @@ diff -aur coreutils-8.32/src/copy.c coreutils-8.32-patched/src/copy.c
|
|||||||
+ file_size_format ( cProgressField[1] + iBarLength - 9, g_iTotalSize, 1 );
|
+ file_size_format ( cProgressField[1] + iBarLength - 9, g_iTotalSize, 1 );
|
||||||
+
|
+
|
||||||
+ /* show how many files were written */
|
+ /* show how many files were written */
|
||||||
+ int sum_length = sprintf ( cProgressField[1], "%d files copied so far...", g_iFilesCopied );
|
+ int sum_length = 0;
|
||||||
|
+ sum_length = sprintf ( cProgressField[1],
|
||||||
|
+ x->move_mode
|
||||||
|
+ ? "%d of %d files moved so far"
|
||||||
|
+ : "%d of %d files copied so far", g_iFilesCopied, g_iTotalFiles );
|
||||||
+ cProgressField[1][sum_length] = ' ';
|
+ cProgressField[1][sum_length] = ' ';
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
@@ -294,7 +386,7 @@ 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 +1543,9 @@
|
@@ -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,
|
||||||
@@ -305,11 +397,13 @@ diff -aur coreutils-8.32/src/copy.c coreutils-8.32-patched/src/copy.c
|
|||||||
goto preserve_metadata;
|
goto preserve_metadata;
|
||||||
|
|
||||||
if (! normal_copy_required)
|
if (! normal_copy_required)
|
||||||
@@ -1328,11 +1557,12 @@
|
@@ -1328,11 +1648,14 @@
|
||||||
|
|
||||||
off_t n_read;
|
off_t n_read;
|
||||||
bool wrote_hole_at_eof;
|
bool wrote_hole_at_eof;
|
||||||
|
+
|
||||||
+ 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};
|
||||||
|
+
|
||||||
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,
|
||||||
@@ -321,22 +415,20 @@ diff -aur coreutils-8.32/src/copy.c coreutils-8.32-patched/src/copy.c
|
|||||||
{
|
{
|
||||||
return_val = false;
|
return_val = false;
|
||||||
goto close_src_and_dst_desc;
|
goto close_src_and_dst_desc;
|
||||||
@@ -1343,6 +1573,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 +1954,15 @@
|
@@ -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)
|
||||||
@@ -355,9 +447,9 @@ diff -aur coreutils-8.32/src/copy.c coreutils-8.32-patched/src/copy.c
|
|||||||
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 2021-08-11 19:40:37.729820358 +0200
|
+++ coreutils-8.32-patched-nc/src/copy.h 2022-02-14 21:14:14.175156795 +0100
|
||||||
@@ -234,6 +234,9 @@
|
@@ -234,6 +234,9 @@
|
||||||
Create destination directories as usual. */
|
Create destination directories as usual. */
|
||||||
bool symbolic_link;
|
bool symbolic_link;
|
||||||
@@ -368,25 +460,32 @@ diff -aur coreutils-8.32/src/copy.h coreutils-8.32-patched/src/copy.h
|
|||||||
/* 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 +307,15 @@
|
@@ -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);
|
||||||
|
|
||||||
+/* BEGIN OF PROGRESS MOD */
|
+/* BEGIN progress mod */
|
||||||
|
+FILE * spawn( const char *cmd, char *const argv[] );
|
||||||
|
+void format_time ( char * _cDst, double seconds, bool showall );
|
||||||
|
+
|
||||||
+int file_size_format ( char * _cDst, long _lSize, int _iCounter );
|
+int file_size_format ( char * _cDst, long _lSize, int _iCounter );
|
||||||
+
|
+
|
||||||
+__attribute__((__common__)) long g_iTotalSize;
|
+__attribute__((__common__)) long g_iTotalSize;
|
||||||
|
+__attribute__((__common__)) long g_iFTotalSize;
|
||||||
+__attribute__((__common__)) long g_iTotalWritten;
|
+__attribute__((__common__)) long g_iTotalWritten;
|
||||||
|
+__attribute__((__common__)) long g_iFTotalWritten;
|
||||||
+__attribute__((__common__)) int g_iFilesCopied;
|
+__attribute__((__common__)) int g_iFilesCopied;
|
||||||
|
+__attribute__((__common__)) int g_iDirectoriesCopied;
|
||||||
+__attribute__((__common__)) struct timeval g_oStartTime;
|
+__attribute__((__common__)) struct timeval g_oStartTime;
|
||||||
|
+__attribute__((__common__)) struct timeval g_oFStartTime;
|
||||||
+__attribute__((__common__)) int g_iTotalFiles;
|
+__attribute__((__common__)) int g_iTotalFiles;
|
||||||
+__attribute__((__common__)) bool progress;
|
+__attribute__((__common__)) bool progress;
|
||||||
+/* END OF 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 2021-08-11 19:40:37.729820358 +0200
|
+++ coreutils-8.32-patched-nc/src/cp.c 2022-02-14 21:14:14.175156795 +0100
|
||||||
@@ -131,6 +131,7 @@
|
@@ -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'},
|
||||||
@@ -395,31 +494,42 @@ diff -aur coreutils-8.32/src/cp.c coreutils-8.32-patched/src/cp.c
|
|||||||
{"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 +171,7 @@
|
@@ -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\
|
||||||
+ -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\
|
||||||
|
+ reflink will be automatically disabled\n\
|
||||||
-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 +637,70 @@
|
@@ -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]));
|
||||||
}
|
}
|
||||||
|
+ /* BEGIN progress mod */
|
||||||
+ struct timeval start_time;
|
+ struct timeval start_time;
|
||||||
+ if (progress) {
|
+ if (progress) {
|
||||||
+ /* BEGIN progress mod */
|
+ if (g_iTotalSize == 0)
|
||||||
+ g_iTotalSize = 0;
|
+ g_iTotalSize = 0;
|
||||||
+ g_iTotalFiles = 0;
|
+ if (g_iTotalFiles == 0)
|
||||||
+ g_iFilesCopied = 0;
|
+ g_iTotalFiles = n_files;
|
||||||
+ g_iTotalWritten = 0;
|
+ if (g_iFilesCopied == 0)
|
||||||
|
+ g_iFilesCopied = 0;
|
||||||
|
+ if (g_iDirectoriesCopied == 0)
|
||||||
|
+ g_iDirectoriesCopied = 0;
|
||||||
|
+ if (g_iTotalWritten == 0)
|
||||||
|
+ g_iTotalWritten = 0;
|
||||||
|
+
|
||||||
|
+ if (target_directory_operand (file[0], &sb, &new_dst, forcing))
|
||||||
|
+ g_iDirectoriesCopied++;
|
||||||
+
|
+
|
||||||
+ /* save time */
|
+ /* save time */
|
||||||
+ gettimeofday ( & start_time, NULL );
|
+ gettimeofday ( & start_time, NULL );
|
||||||
+ g_oStartTime = start_time;
|
+ g_oStartTime = start_time;
|
||||||
+
|
+
|
||||||
+ printf ( "Calculating total size... \r" );
|
+ printf ( "calculating total size... \r" );
|
||||||
+ fflush ( stdout );
|
+ fflush ( stdout );
|
||||||
+ long iTotalSize = 0;
|
+ long iTotalSize = 0;
|
||||||
+ int iFiles = n_files;
|
+ int iFiles = n_files;
|
||||||
@@ -428,31 +538,36 @@ diff -aur coreutils-8.32/src/cp.c coreutils-8.32-patched/src/cp.c
|
|||||||
+ int j;
|
+ int j;
|
||||||
+
|
+
|
||||||
+ /* how many files are we copying */
|
+ /* how many files are we copying */
|
||||||
+ char command[1024];
|
|
||||||
+ sprintf( command, "find \"%s\" -type f | wc -l", file[0]);
|
|
||||||
+ FILE *fp ;
|
+ FILE *fp ;
|
||||||
+ char output[1024];
|
+ char output[1024];
|
||||||
+ fp = popen(command,"r");
|
+ char fcmd[] = "find";
|
||||||
+ if ( fp == NULL || fgets(output, sizeof(output)-1, fp) == NULL)
|
+ fp = spawn(fcmd, (char *[]){ fcmd, file[0], "-type", "f", NULL });
|
||||||
+ printf("failed to run find.\n");
|
+ if ( fp == NULL)
|
||||||
|
+ printf("failed to run find\r");
|
||||||
+ else
|
+ else
|
||||||
+ g_iTotalFiles = atoi( output ) ;
|
+ {
|
||||||
|
+ char *line_buf = NULL;
|
||||||
|
+ size_t line_buf_size = 0;
|
||||||
|
+ int line_count = 0;
|
||||||
|
+ ssize_t line_size;
|
||||||
|
+ line_size = getline(&line_buf, &line_buf_size, fp);
|
||||||
|
+ while (line_size > 0)
|
||||||
|
+ {
|
||||||
|
+ line_count++;
|
||||||
|
+ line_size = getline(&line_buf, &line_buf_size, fp);
|
||||||
|
+ }
|
||||||
|
+ free (line_buf);
|
||||||
|
+ if ( line_count > n_files )
|
||||||
|
+ g_iTotalFiles = line_count;
|
||||||
|
+ }
|
||||||
+
|
+
|
||||||
+ for (j = 0; j < iFiles; j++)
|
+ for (j = 0; j < iFiles; j++)
|
||||||
+ {
|
+ {
|
||||||
+ /* call du -s for each file */
|
+ /* call du -s for each file */
|
||||||
+ /* create command */
|
+ char dcmd[] = "du";
|
||||||
+ char command[1024];
|
+ fp = spawn(dcmd, (char *[]){ dcmd, "-s", file[j], NULL });
|
||||||
+ sprintf ( command, "du -s \"%s\"", file[j] );
|
|
||||||
+ /* TODO: replace all quote signs in file[i] */
|
|
||||||
+
|
|
||||||
+ FILE *fp;
|
|
||||||
+ char output[1024];
|
|
||||||
+
|
|
||||||
+ /* run command */
|
|
||||||
+ fp = popen(command, "r");
|
|
||||||
+ if (fp == NULL || fgets(output, sizeof(output)-1, fp) == NULL) {
|
+ if (fp == NULL || fgets(output, sizeof(output)-1, fp) == NULL) {
|
||||||
+ printf("failed to run du.\n" );
|
+ printf("failed to run du\r" );
|
||||||
+ }
|
+ }
|
||||||
+ else
|
+ else
|
||||||
+ {
|
+ {
|
||||||
@@ -460,26 +575,26 @@ diff -aur coreutils-8.32/src/cp.c coreutils-8.32-patched/src/cp.c
|
|||||||
+ strchr ( output, '\t' )[0] = '\0';
|
+ strchr ( output, '\t' )[0] = '\0';
|
||||||
+ iTotalSize += atol ( output );
|
+ iTotalSize += atol ( output );
|
||||||
+
|
+
|
||||||
+ printf ( "Calculating total size... %ld\r", iTotalSize );
|
+ printf ( "calculating total size... %ld\r", iTotalSize );
|
||||||
+ fflush ( stdout );
|
+ fflush ( stdout );
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ /* close */
|
+ /* close */
|
||||||
+ pclose(fp);
|
+ pclose(fp);
|
||||||
+ }
|
+ }
|
||||||
+ g_iTotalSize = iTotalSize;
|
+ g_iTotalSize += iTotalSize;
|
||||||
+ /* END progress mod */
|
|
||||||
+ }
|
+ }
|
||||||
|
+ /* END progress mod */
|
||||||
+
|
+
|
||||||
|
|
||||||
if (target_directory)
|
if (target_directory)
|
||||||
{
|
{
|
||||||
@@ -777,6 +843,46 @@
|
@@ -777,6 +859,56 @@
|
||||||
ok = copy (source, new_dest, 0, x, &unused, NULL);
|
ok = copy (source, new_dest, 0, x, &unused, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ /* BEGIN progress mod */
|
||||||
+ if (progress) {
|
+ if (progress) {
|
||||||
+ /* BEGIN progress mod */
|
|
||||||
+ /* remove everything */
|
+ /* remove everything */
|
||||||
+ int i;
|
+ int i;
|
||||||
+ if ( g_iTotalFiles > 1 )
|
+ if ( g_iTotalFiles > 1 )
|
||||||
@@ -513,15 +628,25 @@ diff -aur coreutils-8.32/src/cp.c coreutils-8.32-patched/src/cp.c
|
|||||||
+ file_size_format ( s_copy_speed, copy_speed, 1 );
|
+ file_size_format ( s_copy_speed, copy_speed, 1 );
|
||||||
+
|
+
|
||||||
+ /* good-bye message */
|
+ /* good-bye message */
|
||||||
+ printf ( "%d files (%s) copied in %.1f seconds (%s/s).\n", g_iFilesCopied, sTotalWritten,
|
+ char sFType[20];
|
||||||
+ sec_elapsed, s_copy_speed );
|
+ if ( g_iDirectoriesCopied > 0 && g_iDirectoriesCopied == g_iFilesCopied )
|
||||||
+ /* END progress mod */
|
+ sprintf ( sFType, "%s", "folder(s)" );
|
||||||
|
+ else if ( g_iDirectoriesCopied > 0 && g_iDirectoriesCopied < g_iFilesCopied )
|
||||||
|
+ sprintf ( sFType, "%s", "folder(s)/file(s)" );
|
||||||
|
+ else
|
||||||
|
+ sprintf ( sFType, "%s", "file(s)" );
|
||||||
|
+
|
||||||
|
+ char f_time[20];
|
||||||
|
+ format_time(f_time, sec_elapsed, false);
|
||||||
|
+ printf ( "%d %s (%s) copied in %s (%s/s).\n", g_iFilesCopied, sFType,
|
||||||
|
+ sTotalWritten, f_time, s_copy_speed );
|
||||||
+ }
|
+ }
|
||||||
|
+ /* END progress mod */
|
||||||
+
|
+
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -812,6 +918,7 @@
|
@@ -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;
|
||||||
@@ -529,7 +654,7 @@ diff -aur coreutils-8.32/src/cp.c coreutils-8.32-patched/src/cp.c
|
|||||||
x->set_mode = false;
|
x->set_mode = false;
|
||||||
x->mode = 0;
|
x->mode = 0;
|
||||||
|
|
||||||
@@ -950,7 +1057,7 @@
|
@@ -950,7 +1083,7 @@
|
||||||
selinux_enabled = (0 < is_selinux_enabled ());
|
selinux_enabled = (0 < is_selinux_enabled ());
|
||||||
cp_option_init (&x);
|
cp_option_init (&x);
|
||||||
|
|
||||||
@@ -538,7 +663,7 @@ diff -aur coreutils-8.32/src/cp.c coreutils-8.32-patched/src/cp.c
|
|||||||
long_opts, NULL))
|
long_opts, NULL))
|
||||||
!= -1)
|
!= -1)
|
||||||
{
|
{
|
||||||
@@ -1007,6 +1114,10 @@
|
@@ -1007,6 +1140,10 @@
|
||||||
x.unlink_dest_after_failed_open = true;
|
x.unlink_dest_after_failed_open = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -549,77 +674,105 @@ diff -aur coreutils-8.32/src/cp.c coreutils-8.32-patched/src/cp.c
|
|||||||
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 2021-08-11 19:40:37.729820358 +0200
|
+++ coreutils-8.32-patched-nc/src/mv.c 2022-02-14 21:14:14.175156795 +0100
|
||||||
@@ -66,6 +66,7 @@
|
@@ -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'},
|
||||||
+ {"progress-ar", no_argument, NULL, 'g'},
|
+ {"progress-bar", no_argument, NULL, 'g'},
|
||||||
{GETOPT_HELP_OPTION_DECL},
|
{GETOPT_HELP_OPTION_DECL},
|
||||||
{GETOPT_VERSION_OPTION_DECL},
|
{GETOPT_VERSION_OPTION_DECL},
|
||||||
{NULL, 0, NULL, 0}
|
{NULL, 0, NULL, 0}
|
||||||
@@ -168,10 +169,86 @@
|
@@ -170,8 +171,130 @@
|
||||||
static bool
|
|
||||||
do_move (const char *source, const char *dest, const struct cp_options *x)
|
|
||||||
{
|
{
|
||||||
+ struct timeval start_time;
|
|
||||||
+
|
|
||||||
bool copy_into_self;
|
bool copy_into_self;
|
||||||
bool rename_succeeded;
|
bool rename_succeeded;
|
||||||
|
+
|
||||||
|
+ /* BEGIN progress mod */
|
||||||
|
+ struct timeval start_time;
|
||||||
|
+
|
||||||
+ if(progress && x->rename_errno != 0) {
|
+ if(progress && x->rename_errno != 0) {
|
||||||
+ /* BEGIN progress mod */
|
+ if (g_iTotalSize == 0)
|
||||||
+ g_iTotalSize = 0;
|
+ g_iTotalSize = 0;
|
||||||
+ g_iFilesCopied = 0;
|
+ if (g_iTotalFiles == 0)
|
||||||
+ g_iTotalWritten = 0;
|
+ g_iTotalFiles = 0;
|
||||||
|
+ if (g_iFilesCopied == 0)
|
||||||
|
+ g_iFilesCopied = 0;
|
||||||
|
+ if (g_iDirectoriesCopied == 0)
|
||||||
|
+ g_iDirectoriesCopied = 0;
|
||||||
|
+ if (g_iTotalWritten == 0)
|
||||||
|
+ g_iTotalWritten = 0;
|
||||||
|
+
|
||||||
|
+ if (target_directory_operand (source))
|
||||||
|
+ g_iDirectoriesCopied++;
|
||||||
+
|
+
|
||||||
+ gettimeofday (& start_time, NULL);
|
+ gettimeofday (& start_time, NULL);
|
||||||
+ g_oStartTime = start_time;
|
+ g_oStartTime = start_time;
|
||||||
+
|
+
|
||||||
+ printf ("Calculating total size... \r");
|
+ /* how many files are we copying */
|
||||||
|
+ FILE *fp ;
|
||||||
|
+ char output[1024];
|
||||||
|
+ char fcmd[] = "find";
|
||||||
|
+ fp = spawn(fcmd, (char *[]){ fcmd, (char *)source, "-type", "f", NULL });
|
||||||
|
+ if ( fp == NULL)
|
||||||
|
+ printf("failed to run find\r");
|
||||||
|
+ else
|
||||||
|
+ {
|
||||||
|
+ char *line_buf = NULL;
|
||||||
|
+ size_t line_buf_size = 0;
|
||||||
|
+ int line_count = 0;
|
||||||
|
+ ssize_t line_size;
|
||||||
|
+ line_size = getline(&line_buf, &line_buf_size, fp);
|
||||||
|
+ while (line_size > 0)
|
||||||
|
+ {
|
||||||
|
+ line_count++;
|
||||||
|
+ line_size = getline(&line_buf, &line_buf_size, fp);
|
||||||
|
+ }
|
||||||
|
+ free (line_buf);
|
||||||
|
+ g_iTotalFiles = line_count;
|
||||||
|
+ }
|
||||||
|
+ /* close */
|
||||||
|
+ pclose(fp);
|
||||||
|
+
|
||||||
|
+ printf ("calculating total size... \r");
|
||||||
+ fflush (stdout);
|
+ fflush (stdout);
|
||||||
+ long iTotalSize = 0;
|
+ long iTotalSize = 0;
|
||||||
+ /* call du -s for each file */
|
+ /* call du -s for each file */
|
||||||
+ /* create command */
|
+ char dcmd[] = "du";
|
||||||
+ char command[1024];
|
+ fp = spawn(dcmd, (char *[]){ dcmd, "-s", (unsigned char *)(size_t)source, NULL });
|
||||||
+ sprintf ( command, "du -s '%s'", source );
|
|
||||||
+ /* TODO: replace all quote signs in file[i] */
|
|
||||||
+
|
|
||||||
+ FILE *fp;
|
|
||||||
+ char output[1024];
|
|
||||||
+
|
|
||||||
+ /* run command */
|
|
||||||
+ fp = popen(command, "r");
|
|
||||||
+ if (fp == NULL || fgets(output, sizeof(output)-1, fp) == NULL) {
|
+ if (fp == NULL || fgets(output, sizeof(output)-1, fp) == NULL) {
|
||||||
+ //printf("failed to run du.\n" );
|
+ printf("failed to run du\r" );
|
||||||
+ }
|
+ }
|
||||||
+ else
|
+ else
|
||||||
+ {
|
+ {
|
||||||
+ /* isolate size */
|
+ /* isolate size */
|
||||||
+ strchr ( output, '\t' )[0] = '\0';
|
+ strchr ( output, '\t' )[0] = '\0';
|
||||||
+ iTotalSize += atol ( output );
|
+ iTotalSize += atol ( output );
|
||||||
+ printf ( "Calculating total size... %ld\r", iTotalSize );
|
+ printf ( "calculating total size... %ld\r", iTotalSize );
|
||||||
+ fflush ( stdout );
|
+ fflush ( stdout );
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ /* close */
|
+ /* close */
|
||||||
+ pclose(fp);
|
+ pclose(fp);
|
||||||
+ g_iTotalSize = iTotalSize;
|
+ g_iTotalSize += iTotalSize;
|
||||||
+ /* END progress mod */
|
|
||||||
+
|
|
||||||
+ }
|
+ }
|
||||||
|
+ /* END progress mod */
|
||||||
+
|
+
|
||||||
bool ok = copy (source, dest, false, x, ©_into_self, &rename_succeeded);
|
bool ok = copy (source, dest, false, x, ©_into_self, &rename_succeeded);
|
||||||
|
|
||||||
|
+ /* BEGIN progress mod */
|
||||||
+ if (progress && (x->rename_errno != 0 && ok)) {
|
+ if (progress && (x->rename_errno != 0 && ok)) {
|
||||||
+ /* BEGIN progress mod */
|
|
||||||
+ /* remove everything */
|
+ /* remove everything */
|
||||||
+ int i;
|
+ int i;
|
||||||
+ int limit = (g_iTotalFiles > 1 ? 6 : 3);
|
+ int limit = (g_iTotalFiles > 1 ? 6 : 3);
|
||||||
+ for ( i = 0; i < limit; i++ )
|
+ if (!rename_succeeded)
|
||||||
+ printf ( "\033[K\n" );
|
+ {
|
||||||
+ printf ( "\r\033[3A" );
|
+ for ( i = 0; i < limit; i++ )
|
||||||
|
+ printf ( "\033[K\n" );
|
||||||
|
+ printf ( "\r\033[3A" );
|
||||||
|
+ }
|
||||||
+
|
+
|
||||||
+ /* save time */
|
+ /* save time */
|
||||||
+ struct timeval end_time;
|
+ struct timeval end_time;
|
||||||
@@ -638,16 +791,32 @@ diff -aur coreutils-8.32/src/mv.c coreutils-8.32-patched/src/mv.c
|
|||||||
+ char s_copy_speed[20];
|
+ char s_copy_speed[20];
|
||||||
+ file_size_format ( s_copy_speed, copy_speed, 1 );
|
+ file_size_format ( s_copy_speed, copy_speed, 1 );
|
||||||
+
|
+
|
||||||
|
+ /* increase counter */
|
||||||
|
+ g_iFilesCopied++;
|
||||||
|
+
|
||||||
+ /* good-bye message */
|
+ /* good-bye message */
|
||||||
+ printf ( "%d files (%s) moved in %.1f seconds (%s/s).\n", g_iFilesCopied, sTotalWritten,
|
+ if ( x->last_file )
|
||||||
+ sec_elapsed, s_copy_speed );
|
+ {
|
||||||
+ /* END progress mod */
|
+ char sFType[20];
|
||||||
|
+ if ( g_iDirectoriesCopied > 0 && g_iDirectoriesCopied == g_iFilesCopied )
|
||||||
|
+ sprintf ( sFType, "%s", "folder(s)" );
|
||||||
|
+ else if ( g_iDirectoriesCopied > 0 && g_iDirectoriesCopied < g_iFilesCopied )
|
||||||
|
+ sprintf ( sFType, "%s", "folder(s)/file(s)" );
|
||||||
|
+ else
|
||||||
|
+ sprintf ( sFType, "%s", "file(s)" );
|
||||||
|
+
|
||||||
|
+ char f_time[20];
|
||||||
|
+ format_time(f_time, sec_elapsed, false);
|
||||||
|
+ printf ( "%d %s (%s) moved in %s (%s/s).\n", g_iFilesCopied, sFType,
|
||||||
|
+ sTotalWritten, f_time, s_copy_speed );
|
||||||
|
+ }
|
||||||
+ }
|
+ }
|
||||||
|
+ /* END progress mod */
|
||||||
+
|
+
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
char const *dir_to_remove;
|
char const *dir_to_remove;
|
||||||
@@ -306,6 +383,7 @@
|
@@ -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\
|
||||||
@@ -655,7 +824,7 @@ diff -aur coreutils-8.32/src/mv.c coreutils-8.32-patched/src/mv.c
|
|||||||
-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 +439,7 @@
|
@@ -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 ();
|
||||||
|
|
||||||
@@ -664,15 +833,13 @@ diff -aur coreutils-8.32/src/mv.c coreutils-8.32-patched/src/mv.c
|
|||||||
!= -1)
|
!= -1)
|
||||||
{
|
{
|
||||||
switch (c)
|
switch (c)
|
||||||
@@ -407,6 +485,11 @@
|
@@ -407,6 +531,9 @@
|
||||||
case 'v':
|
case 'v':
|
||||||
x.verbose = true;
|
x.verbose = true;
|
||||||
break;
|
break;
|
||||||
+
|
|
||||||
+ case 'g':
|
+ case 'g':
|
||||||
+ progress = true;
|
+ progress = true;
|
||||||
+ break;
|
+ break;
|
||||||
+
|
|
||||||
case 'S':
|
case 'S':
|
||||||
make_backups = true;
|
make_backups = true;
|
||||||
backup_suffix = optarg;
|
backup_suffix = optarg;
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
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 07:31:05.000000000 -0400
|
--- coreutils-9.0/src/copy.c 2021-09-24 13:31:05.000000000 +0200
|
||||||
+++ coreutils-9.0-patched/src/copy.c 2021-10-27 21:33:32.299248300 -0400
|
+++ coreutils-9.0-patched-nc/src/copy.c 2022-02-14 21:14:14.183157065 +0100
|
||||||
@@ -129,6 +129,70 @@
|
@@ -129,6 +129,133 @@
|
||||||
dev_t dev;
|
dev_t dev;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
+/* BEGIN progress mod */
|
||||||
+struct progress_status {
|
+struct progress_status {
|
||||||
+ int iCountDown;
|
+ int iCountDown;
|
||||||
+ char ** cProgressField;
|
+ char ** cProgressField;
|
||||||
@@ -13,7 +14,69 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c
|
|||||||
+ struct stat src_open_sb;
|
+ struct stat src_open_sb;
|
||||||
+};
|
+};
|
||||||
+
|
+
|
||||||
+/* Begin progress Mod*/
|
+FILE * spawn( const char *cmd, char *const argv[] )
|
||||||
|
+{
|
||||||
|
+ FILE *ret = NULL;
|
||||||
|
+ int pfd_read[2];
|
||||||
|
+ pid_t pid;
|
||||||
|
+
|
||||||
|
+ if (cmd == NULL || argv == NULL)
|
||||||
|
+ return ret;
|
||||||
|
+
|
||||||
|
+ if (pipe(pfd_read) < 0) {
|
||||||
|
+ error(0, errno, "pipe: %s", cmd);
|
||||||
|
+ return ret;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if ((pid = fork()) == 0) {
|
||||||
|
+ int err = dup2(pfd_read[1], 1) < 0;
|
||||||
|
+ close(pfd_read[0]);
|
||||||
|
+ close(pfd_read[1]);
|
||||||
|
+
|
||||||
|
+ if (err)
|
||||||
|
+ error(EXIT_FAILURE, errno, "dup2: %s", cmd);
|
||||||
|
+ execvp(cmd, argv);
|
||||||
|
+ error(EXIT_FAILURE, errno, "exec: %s", cmd);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ close(pfd_read[1]);
|
||||||
|
+
|
||||||
|
+ if (pid < 0) {
|
||||||
|
+ close(pfd_read[0]);
|
||||||
|
+ error(0, errno, "fork: %s", cmd);
|
||||||
|
+ return ret;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ ret = fdopen(pfd_read[0], "r");
|
||||||
|
+ return ret;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void format_time ( char * _cDest, double seconds, bool showall )
|
||||||
|
+{
|
||||||
|
+ // hours
|
||||||
|
+ int hr = ( (int) seconds / (60 * 60)) % 24;
|
||||||
|
+ // minutes
|
||||||
|
+ int min = ( (int) seconds / 60) % 60;
|
||||||
|
+ // seconds
|
||||||
|
+ double sec = seconds - (hr * (60 * 60)) - (min * 60);
|
||||||
|
+ if ( showall )
|
||||||
|
+ {
|
||||||
|
+ if ( seconds < 0 )
|
||||||
|
+ sprintf(_cDest, "%2ch %2cm %2cs", '0', '0', '?');
|
||||||
|
+ else
|
||||||
|
+ sprintf(_cDest, "%2dh %2dm %2ds", hr, min, (int) sec);
|
||||||
|
+ } else if ( seconds >= 3600 )
|
||||||
|
+ {
|
||||||
|
+ sprintf(_cDest, "%2dh %2dm %4.1fs", hr, min, sec);
|
||||||
|
+ } else if ( seconds >= 60 )
|
||||||
|
+ {
|
||||||
|
+ sprintf(_cDest, "%2dm %4.1fs", min, sec);
|
||||||
|
+ } else
|
||||||
|
+ {
|
||||||
|
+ sprintf(_cDest, "%4.1fs", sec);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
+static void file_progress_bar ( char * _cDest, int _iBarLength, long _lProgress, long _lTotal )
|
+static void file_progress_bar ( char * _cDest, int _iBarLength, long _lProgress, long _lTotal )
|
||||||
+{
|
+{
|
||||||
+ double dPercent = (double) _lProgress / (double) _lTotal * 100.f;
|
+ double dPercent = (double) _lProgress / (double) _lTotal * 100.f;
|
||||||
@@ -72,7 +135,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. */
|
/* Initial size of the cp.dest_info hash table. */
|
||||||
#define DEST_INFO_INITIAL_CAPACITY 61
|
#define DEST_INFO_INITIAL_CAPACITY 61
|
||||||
|
|
||||||
@@ -299,10 +363,11 @@
|
@@ -299,14 +426,23 @@
|
||||||
bytes read. */
|
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,
|
||||||
@@ -86,13 +149,25 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c
|
|||||||
{
|
{
|
||||||
*last_write_made_hole = false;
|
*last_write_made_hole = false;
|
||||||
*total_n_read = 0;
|
*total_n_read = 0;
|
||||||
@@ -362,6 +427,85 @@
|
|
||||||
|
+ /* 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 +498,103 @@
|
||||||
|
|
||||||
while (max_n_read)
|
while (max_n_read)
|
||||||
{
|
{
|
||||||
+
|
+
|
||||||
|
+ /* BEGIN progress mod */
|
||||||
+ if (progress) {
|
+ if (progress) {
|
||||||
+ /* BEGIN progress mod */
|
|
||||||
+ /* update countdown */
|
+ /* update countdown */
|
||||||
+ s_progress->iCountDown--;
|
+ s_progress->iCountDown--;
|
||||||
+ char * sProgressBar = s_progress->cProgressField[5];
|
+ char * sProgressBar = s_progress->cProgressField[5];
|
||||||
@@ -106,6 +181,7 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c
|
|||||||
+ struct timeval cur_time;
|
+ struct timeval cur_time;
|
||||||
+ gettimeofday ( & cur_time, NULL );
|
+ gettimeofday ( & cur_time, NULL );
|
||||||
+ int cur_size = g_iTotalWritten + *total_n_read / 1024;
|
+ 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;
|
+ int usec_elapsed = cur_time.tv_usec - s_progress->last_time.tv_usec;
|
||||||
+ double sec_elapsed = ( double ) usec_elapsed / 1000000.f;
|
+ double sec_elapsed = ( double ) usec_elapsed / 1000000.f;
|
||||||
+ sec_elapsed += ( double ) ( cur_time.tv_sec - s_progress->last_time.tv_sec );
|
+ sec_elapsed += ( double ) ( cur_time.tv_sec - s_progress->last_time.tv_sec );
|
||||||
@@ -119,18 +195,35 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c
|
|||||||
+
|
+
|
||||||
+ /* how many time has passed since the start? */
|
+ /* how many time has passed since the start? */
|
||||||
+ int isec_elapsed = cur_time.tv_sec - g_oStartTime.tv_sec;
|
+ 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
|
+ int sec_remaining = ( int ) ( ( double ) isec_elapsed / cur_size
|
||||||
+ * g_iTotalSize ) - isec_elapsed;
|
+ * g_iTotalSize ) - isec_elapsed;
|
||||||
+ int min_remaining = sec_remaining / 60;
|
+ int sec_fremaining = ( int ) ( ( double ) isec_felapsed / cur_fsize
|
||||||
+ sec_remaining -= min_remaining * 60;
|
+ * g_iFTotalSize ) - isec_felapsed;
|
||||||
+ int hours_remaining = min_remaining / 60;
|
|
||||||
+ min_remaining -= hours_remaining * 60;
|
|
||||||
+ /* print out */
|
+ /* print out */
|
||||||
|
+
|
||||||
|
+ char f_ttime[20];
|
||||||
|
+ char f_ftime[20];
|
||||||
|
+ format_time(f_ttime, sec_remaining, true);
|
||||||
|
+ format_time(f_ftime, sec_fremaining, true);
|
||||||
|
+
|
||||||
|
+ sprintf ( s_progress->cProgressField[1],
|
||||||
|
+ move_mode
|
||||||
|
+ ? "%d of %d files moved (about %s remaining) "
|
||||||
|
+ : "%d of %d files copied (about %s remaining) ",
|
||||||
|
+ g_iFilesCopied, g_iTotalFiles, f_ttime );
|
||||||
|
+
|
||||||
|
+ char s_ftime[40] = "";
|
||||||
|
+
|
||||||
|
+ if (g_iTotalFiles > 1)
|
||||||
|
+ sprintf ( s_ftime, "(about %s remaining)", f_ftime );
|
||||||
|
+ else
|
||||||
|
+ sprintf ( s_ftime, "(about %s remaining)", f_ttime );
|
||||||
|
+
|
||||||
+ sprintf ( s_progress->cProgressField[3],
|
+ sprintf ( s_progress->cProgressField[3],
|
||||||
+ move_mode
|
+ move_mode
|
||||||
+ ? "Moving at %s/s (about %uh %um %us remaining)"
|
+ ? "moving at %s/s %s"
|
||||||
+ : "Copying at %s/s (about %uh %um %us remaining)", s_copy_speed,
|
+ : "copying at %s/s %s", s_copy_speed, s_ftime );
|
||||||
+ hours_remaining, min_remaining, sec_remaining );
|
|
||||||
+
|
+
|
||||||
+ int fs_len;
|
+ int fs_len;
|
||||||
+ if ( g_iTotalFiles > 1 )
|
+ if ( g_iTotalFiles > 1 )
|
||||||
@@ -166,13 +259,13 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c
|
|||||||
+ printf ( "\r\033[3A" );
|
+ printf ( "\r\033[3A" );
|
||||||
+ fflush ( stdout );
|
+ fflush ( stdout );
|
||||||
+ }
|
+ }
|
||||||
+ /* END progress mod */
|
|
||||||
+ }
|
+ }
|
||||||
|
+ /* END progress mod */
|
||||||
+
|
+
|
||||||
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 +590,14 @@
|
@@ -446,6 +679,14 @@
|
||||||
certain files in /proc or /sys with linux kernels. */
|
certain files in /proc or /sys with linux kernels. */
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,7 +280,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
|
/* 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))
|
||||||
@@ -516,9 +668,11 @@
|
@@ -516,9 +757,11 @@
|
||||||
static bool
|
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,
|
||||||
@@ -201,7 +294,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_start = 0;
|
||||||
off_t last_ext_len = 0;
|
off_t last_ext_len = 0;
|
||||||
@@ -590,10 +744,16 @@
|
@@ -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;
|
||||||
@@ -220,7 +313,7 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
dest_pos = ext_start + n_read;
|
dest_pos = ext_start + n_read;
|
||||||
@@ -1374,8 +1534,74 @@
|
@@ -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);
|
||||||
|
|
||||||
@@ -259,7 +352,11 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c
|
|||||||
+ file_size_format ( cProgressField[1] + iBarLength - 9, g_iTotalSize, 1 );
|
+ file_size_format ( cProgressField[1] + iBarLength - 9, g_iTotalSize, 1 );
|
||||||
+
|
+
|
||||||
+ /* show how many files were written */
|
+ /* show how many files were written */
|
||||||
+ int sum_length = sprintf ( cProgressField[1], "%d files copied so far...", g_iFilesCopied );
|
+ int sum_length = 0;
|
||||||
|
+ sum_length = sprintf ( cProgressField[1],
|
||||||
|
+ x->move_mode
|
||||||
|
+ ? "%d of %d files moved so far"
|
||||||
|
+ : "%d of %d files copied so far", g_iFilesCopied, g_iTotalFiles );
|
||||||
+ cProgressField[1][sum_length] = ' ';
|
+ cProgressField[1][sum_length] = ' ';
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
@@ -291,11 +388,13 @@ 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;
|
||||||
|
+
|
||||||
+ 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};
|
||||||
|
+
|
||||||
if (! (
|
if (! (
|
||||||
#ifdef SEEK_HOLE
|
#ifdef SEEK_HOLE
|
||||||
scantype == LSEEK_SCANTYPE
|
scantype == LSEEK_SCANTYPE
|
||||||
@@ -1383,15 +1609,17 @@
|
@@ -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,
|
||||||
@@ -312,15 +411,15 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c
|
|||||||
- src_name, dst_name, UINTMAX_MAX, &n_read,
|
- src_name, dst_name, UINTMAX_MAX, &n_read,
|
||||||
- &wrote_hole_at_eof)))
|
- &wrote_hole_at_eof)))
|
||||||
+ x->move_mode, src_name, dst_name, UINTMAX_MAX,
|
+ x->move_mode, src_name, dst_name, UINTMAX_MAX,
|
||||||
+ &n_read, &wrote_hole_at_eof, &s_progress)))
|
+ &n_read, &wrote_hole_at_eof, &s_progress)))
|
||||||
{
|
{
|
||||||
return_val = false;
|
return_val = false;
|
||||||
goto close_src_and_dst_desc;
|
goto close_src_and_dst_desc;
|
||||||
@@ -1402,6 +1630,14 @@
|
@@ -1402,6 +1725,14 @@
|
||||||
return_val = false;
|
return_val = false;
|
||||||
goto close_src_and_dst_desc;
|
goto close_src_and_dst_desc;
|
||||||
}
|
}
|
||||||
+ /* BEGIN progress mod */
|
+ /* BEGIN progress mod */
|
||||||
+ if (progress) {
|
+ if (progress) {
|
||||||
+ int i;
|
+ int i;
|
||||||
+ for ( i = 0; i < 6; i++ )
|
+ for ( i = 0; i < 6; i++ )
|
||||||
@@ -331,9 +430,9 @@ 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 07:31:05.000000000 -0400
|
--- coreutils-9.0/src/copy.h 2021-09-24 13:31:05.000000000 +0200
|
||||||
+++ coreutils-9.0-patched/src/copy.h 2021-10-27 21:33:32.299248300 -0400
|
+++ coreutils-9.0-patched-nc/src/copy.h 2022-02-14 21:14:14.183157065 +0100
|
||||||
@@ -236,6 +236,9 @@
|
@@ -236,6 +236,9 @@
|
||||||
Create destination directories as usual. */
|
Create destination directories as usual. */
|
||||||
bool symbolic_link;
|
bool symbolic_link;
|
||||||
@@ -344,25 +443,32 @@ 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
|
/* 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 +311,15 @@
|
@@ -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);
|
||||||
|
|
||||||
+/* BEGIN OF PROGRESS MOD */
|
+/* BEGIN progress mod */
|
||||||
|
+FILE * spawn( const char *cmd, char *const argv[] );
|
||||||
|
+void format_time ( char * _cDst, double seconds, bool showall );
|
||||||
|
+
|
||||||
+int file_size_format ( char * _cDst, long _lSize, int _iCounter );
|
+int file_size_format ( char * _cDst, long _lSize, int _iCounter );
|
||||||
+
|
+
|
||||||
+__attribute__((__common__)) long g_iTotalSize;
|
+__attribute__((__common__)) long g_iTotalSize;
|
||||||
|
+__attribute__((__common__)) long g_iFTotalSize;
|
||||||
+__attribute__((__common__)) long g_iTotalWritten;
|
+__attribute__((__common__)) long g_iTotalWritten;
|
||||||
|
+__attribute__((__common__)) long g_iFTotalWritten;
|
||||||
+__attribute__((__common__)) int g_iFilesCopied;
|
+__attribute__((__common__)) int g_iFilesCopied;
|
||||||
|
+__attribute__((__common__)) int g_iDirectoriesCopied;
|
||||||
+__attribute__((__common__)) struct timeval g_oStartTime;
|
+__attribute__((__common__)) struct timeval g_oStartTime;
|
||||||
|
+__attribute__((__common__)) struct timeval g_oFStartTime;
|
||||||
+__attribute__((__common__)) int g_iTotalFiles;
|
+__attribute__((__common__)) int g_iTotalFiles;
|
||||||
+__attribute__((__common__)) bool progress;
|
+__attribute__((__common__)) bool progress;
|
||||||
+/* END OF 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 07:31:05.000000000 -0400
|
--- coreutils-9.0/src/cp.c 2021-09-24 13:31:05.000000000 +0200
|
||||||
+++ coreutils-9.0-patched/src/cp.c 2021-10-27 21:22:08.913768100 -0400
|
+++ coreutils-9.0-patched-nc/src/cp.c 2022-02-14 21:14:14.183157065 +0100
|
||||||
@@ -131,6 +131,7 @@
|
@@ -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'},
|
||||||
@@ -381,23 +487,32 @@ diff -aur coreutils-9.0/src/cp.c coreutils-9.0-patched/src/cp.c
|
|||||||
-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 +638,70 @@
|
@@ -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]));
|
||||||
}
|
}
|
||||||
|
+ /* BEGIN progress mod */
|
||||||
+ struct timeval start_time;
|
+ struct timeval start_time;
|
||||||
+ if (progress) {
|
+ if (progress) {
|
||||||
+ /* BEGIN progress mod */
|
+ if (g_iTotalSize == 0)
|
||||||
+ g_iTotalSize = 0;
|
+ g_iTotalSize = 0;
|
||||||
+ g_iTotalFiles = 0;
|
+ if (g_iTotalFiles == 0)
|
||||||
+ g_iFilesCopied = 0;
|
+ g_iTotalFiles = n_files;
|
||||||
+ g_iTotalWritten = 0;
|
+ if (g_iFilesCopied == 0)
|
||||||
|
+ g_iFilesCopied = 0;
|
||||||
|
+ if (g_iDirectoriesCopied == 0)
|
||||||
|
+ g_iDirectoriesCopied = 0;
|
||||||
|
+ if (g_iTotalWritten == 0)
|
||||||
|
+ g_iTotalWritten = 0;
|
||||||
|
+
|
||||||
|
+ if (target_directory_operand (file[0], &sb, &new_dst, forcing))
|
||||||
|
+ g_iDirectoriesCopied++;
|
||||||
+
|
+
|
||||||
+ /* save time */
|
+ /* save time */
|
||||||
+ gettimeofday ( & start_time, NULL );
|
+ gettimeofday ( & start_time, NULL );
|
||||||
+ g_oStartTime = start_time;
|
+ g_oStartTime = start_time;
|
||||||
+
|
+
|
||||||
+ printf ( "Calculating total size... \r" );
|
+ printf ( "calculating total size... \r" );
|
||||||
+ fflush ( stdout );
|
+ fflush ( stdout );
|
||||||
+ long iTotalSize = 0;
|
+ long iTotalSize = 0;
|
||||||
+ int iFiles = n_files;
|
+ int iFiles = n_files;
|
||||||
@@ -406,31 +521,36 @@ diff -aur coreutils-9.0/src/cp.c coreutils-9.0-patched/src/cp.c
|
|||||||
+ int j;
|
+ int j;
|
||||||
+
|
+
|
||||||
+ /* how many files are we copying */
|
+ /* how many files are we copying */
|
||||||
+ char command[1024];
|
|
||||||
+ sprintf( command, "find \"%s\" -type f | wc -l", file[0]);
|
|
||||||
+ FILE *fp ;
|
+ FILE *fp ;
|
||||||
+ char output[1024];
|
+ char output[1024];
|
||||||
+ fp = popen(command,"r");
|
+ char fcmd[] = "find";
|
||||||
+ if ( fp == NULL || fgets(output, sizeof(output)-1, fp) == NULL)
|
+ fp = spawn(fcmd, (char *[]){ fcmd, file[0], "-type", "f", NULL });
|
||||||
+ printf("failed to run find.\n");
|
+ if ( fp == NULL)
|
||||||
|
+ printf("failed to run find\r");
|
||||||
+ else
|
+ else
|
||||||
+ g_iTotalFiles = atoi( output ) ;
|
+ {
|
||||||
|
+ char *line_buf = NULL;
|
||||||
|
+ size_t line_buf_size = 0;
|
||||||
|
+ int line_count = 0;
|
||||||
|
+ ssize_t line_size;
|
||||||
|
+ line_size = getline(&line_buf, &line_buf_size, fp);
|
||||||
|
+ while (line_size > 0)
|
||||||
|
+ {
|
||||||
|
+ line_count++;
|
||||||
|
+ line_size = getline(&line_buf, &line_buf_size, fp);
|
||||||
|
+ }
|
||||||
|
+ free (line_buf);
|
||||||
|
+ if ( line_count > n_files )
|
||||||
|
+ g_iTotalFiles = line_count;
|
||||||
|
+ }
|
||||||
+
|
+
|
||||||
+ for (j = 0; j < iFiles; j++)
|
+ for (j = 0; j < iFiles; j++)
|
||||||
+ {
|
+ {
|
||||||
+ /* call du -s for each file */
|
+ /* call du -s for each file */
|
||||||
+ /* create command */
|
+ char dcmd[] = "du";
|
||||||
+ char command[1024];
|
+ fp = spawn(dcmd, (char *[]){ dcmd, "-s", file[j], NULL });
|
||||||
+ sprintf ( command, "du -s \"%s\"", file[j] );
|
|
||||||
+ /* TODO: replace all quote signs in file[i] */
|
|
||||||
+
|
|
||||||
+ FILE *fp;
|
|
||||||
+ char output[1024];
|
|
||||||
+
|
|
||||||
+ /* run command */
|
|
||||||
+ fp = popen(command, "r");
|
|
||||||
+ if (fp == NULL || fgets(output, sizeof(output)-1, fp) == NULL) {
|
+ if (fp == NULL || fgets(output, sizeof(output)-1, fp) == NULL) {
|
||||||
+ printf("failed to run du.\n" );
|
+ printf("failed to run du\r" );
|
||||||
+ }
|
+ }
|
||||||
+ else
|
+ else
|
||||||
+ {
|
+ {
|
||||||
@@ -438,26 +558,26 @@ diff -aur coreutils-9.0/src/cp.c coreutils-9.0-patched/src/cp.c
|
|||||||
+ strchr ( output, '\t' )[0] = '\0';
|
+ strchr ( output, '\t' )[0] = '\0';
|
||||||
+ iTotalSize += atol ( output );
|
+ iTotalSize += atol ( output );
|
||||||
+
|
+
|
||||||
+ printf ( "Calculating total size... %ld\r", iTotalSize );
|
+ printf ( "calculating total size... %ld\r", iTotalSize );
|
||||||
+ fflush ( stdout );
|
+ fflush ( stdout );
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ /* close */
|
+ /* close */
|
||||||
+ pclose(fp);
|
+ pclose(fp);
|
||||||
+ }
|
+ }
|
||||||
+ g_iTotalSize = iTotalSize;
|
+ g_iTotalSize += iTotalSize;
|
||||||
+ /* END progress mod */
|
|
||||||
+ }
|
+ }
|
||||||
|
+ /* END progress mod */
|
||||||
+
|
+
|
||||||
|
|
||||||
if (target_directory)
|
if (target_directory)
|
||||||
{
|
{
|
||||||
@@ -781,6 +849,46 @@
|
@@ -781,6 +863,56 @@
|
||||||
ok = copy (source, new_dest, 0, x, &unused, NULL);
|
ok = copy (source, new_dest, 0, x, &unused, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ /* BEGIN progress mod */
|
||||||
+ if (progress) {
|
+ if (progress) {
|
||||||
+ /* BEGIN progress mod */
|
|
||||||
+ /* remove everything */
|
+ /* remove everything */
|
||||||
+ int i;
|
+ int i;
|
||||||
+ if ( g_iTotalFiles > 1 )
|
+ if ( g_iTotalFiles > 1 )
|
||||||
@@ -491,32 +611,45 @@ diff -aur coreutils-9.0/src/cp.c coreutils-9.0-patched/src/cp.c
|
|||||||
+ file_size_format ( s_copy_speed, copy_speed, 1 );
|
+ file_size_format ( s_copy_speed, copy_speed, 1 );
|
||||||
+
|
+
|
||||||
+ /* good-bye message */
|
+ /* good-bye message */
|
||||||
+ printf ( "%d files (%s) copied in %.1f seconds (%s/s).\n", g_iFilesCopied, sTotalWritten,
|
+ char sFType[20];
|
||||||
+ sec_elapsed, s_copy_speed );
|
+ if ( g_iDirectoriesCopied > 0 && g_iDirectoriesCopied == g_iFilesCopied )
|
||||||
+ /* END progress mod */
|
+ sprintf ( sFType, "%s", "folder(s)" );
|
||||||
|
+ else if ( g_iDirectoriesCopied > 0 && g_iDirectoriesCopied < g_iFilesCopied )
|
||||||
|
+ sprintf ( sFType, "%s", "folder(s)/file(s)" );
|
||||||
|
+ else
|
||||||
|
+ sprintf ( sFType, "%s", "file(s)" );
|
||||||
|
+
|
||||||
|
+ char f_time[20];
|
||||||
|
+ format_time(f_time, sec_elapsed, false);
|
||||||
|
+ printf ( "%d %s (%s) copied in %s (%s/s).\n", g_iFilesCopied, sFType,
|
||||||
|
+ sTotalWritten, f_time, s_copy_speed );
|
||||||
+ }
|
+ }
|
||||||
|
+ /* END progress mod */
|
||||||
+
|
+
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -816,6 +924,7 @@
|
@@ -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;
|
||||||
|
+
|
||||||
+ x->progress_bar = false;
|
+ x->progress_bar = false;
|
||||||
|
+
|
||||||
x->set_mode = false;
|
x->set_mode = false;
|
||||||
x->mode = 0;
|
x->mode = 0;
|
||||||
|
|
||||||
@@ -954,7 +1063,7 @@
|
@@ -954,7 +1089,8 @@
|
||||||
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)
|
||||||
{
|
{
|
||||||
@@ -1011,6 +1120,10 @@
|
@@ -1011,6 +1147,10 @@
|
||||||
x.unlink_dest_after_failed_open = true;
|
x.unlink_dest_after_failed_open = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -527,7 +660,7 @@ diff -aur coreutils-9.0/src/cp.c coreutils-9.0-patched/src/cp.c
|
|||||||
case 'H':
|
case 'H':
|
||||||
x.dereference = DEREF_COMMAND_LINE_ARGUMENTS;
|
x.dereference = DEREF_COMMAND_LINE_ARGUMENTS;
|
||||||
break;
|
break;
|
||||||
@@ -1171,6 +1284,9 @@
|
@@ -1171,6 +1311,9 @@
|
||||||
usage (EXIT_FAILURE);
|
usage (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -537,9 +670,9 @@ diff -aur coreutils-9.0/src/cp.c coreutils-9.0-patched/src/cp.c
|
|||||||
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 07:31:05.000000000 -0400
|
--- coreutils-9.0/src/mv.c 2021-09-24 13:31:05.000000000 +0200
|
||||||
+++ coreutils-9.0-patched/src/mv.c 2021-10-27 21:33:32.299248300 -0400
|
+++ coreutils-9.0-patched-nc/src/mv.c 2022-02-14 21:14:14.183157065 +0100
|
||||||
@@ -66,6 +66,7 @@
|
@@ -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'},
|
||||||
@@ -548,66 +681,94 @@ diff -aur coreutils-9.0/src/mv.c coreutils-9.0-patched/src/mv.c
|
|||||||
{GETOPT_HELP_OPTION_DECL},
|
{GETOPT_HELP_OPTION_DECL},
|
||||||
{GETOPT_VERSION_OPTION_DECL},
|
{GETOPT_VERSION_OPTION_DECL},
|
||||||
{NULL, 0, NULL, 0}
|
{NULL, 0, NULL, 0}
|
||||||
@@ -168,10 +169,86 @@
|
@@ -170,8 +171,130 @@
|
||||||
static bool
|
|
||||||
do_move (char const *source, char const *dest, const struct cp_options *x)
|
|
||||||
{
|
{
|
||||||
+ struct timeval start_time;
|
|
||||||
+
|
|
||||||
bool copy_into_self;
|
bool copy_into_self;
|
||||||
bool rename_succeeded;
|
bool rename_succeeded;
|
||||||
|
+
|
||||||
|
+ /* BEGIN progress mod */
|
||||||
|
+ struct timeval start_time;
|
||||||
|
+
|
||||||
+ if(progress && x->rename_errno != 0) {
|
+ if(progress && x->rename_errno != 0) {
|
||||||
+ /* BEGIN progress mod */
|
+ if (g_iTotalSize == 0)
|
||||||
+ g_iTotalSize = 0;
|
+ g_iTotalSize = 0;
|
||||||
+ g_iFilesCopied = 0;
|
+ if (g_iTotalFiles == 0)
|
||||||
+ g_iTotalWritten = 0;
|
+ g_iTotalFiles = 0;
|
||||||
|
+ if (g_iFilesCopied == 0)
|
||||||
|
+ g_iFilesCopied = 0;
|
||||||
|
+ if (g_iDirectoriesCopied == 0)
|
||||||
|
+ g_iDirectoriesCopied = 0;
|
||||||
|
+ if (g_iTotalWritten == 0)
|
||||||
|
+ g_iTotalWritten = 0;
|
||||||
|
+
|
||||||
|
+ if (target_directory_operand (source))
|
||||||
|
+ g_iDirectoriesCopied++;
|
||||||
+
|
+
|
||||||
+ gettimeofday (& start_time, NULL);
|
+ gettimeofday (& start_time, NULL);
|
||||||
+ g_oStartTime = start_time;
|
+ g_oStartTime = start_time;
|
||||||
+
|
+
|
||||||
+ printf ("Calculating total size... \r");
|
+ /* how many files are we copying */
|
||||||
|
+ FILE *fp ;
|
||||||
|
+ char output[1024];
|
||||||
|
+ char fcmd[] = "find";
|
||||||
|
+ fp = spawn(fcmd, (char *[]){ fcmd, (char *)source, "-type", "f", NULL });
|
||||||
|
+ if ( fp == NULL)
|
||||||
|
+ printf("failed to run find\r");
|
||||||
|
+ else
|
||||||
|
+ {
|
||||||
|
+ char *line_buf = NULL;
|
||||||
|
+ size_t line_buf_size = 0;
|
||||||
|
+ int line_count = 0;
|
||||||
|
+ ssize_t line_size;
|
||||||
|
+ line_size = getline(&line_buf, &line_buf_size, fp);
|
||||||
|
+ while (line_size > 0)
|
||||||
|
+ {
|
||||||
|
+ line_count++;
|
||||||
|
+ line_size = getline(&line_buf, &line_buf_size, fp);
|
||||||
|
+ }
|
||||||
|
+ free (line_buf);
|
||||||
|
+ g_iTotalFiles = line_count;
|
||||||
|
+ }
|
||||||
|
+ /* close */
|
||||||
|
+ pclose(fp);
|
||||||
|
+
|
||||||
|
+ printf ("calculating total size... \r");
|
||||||
+ fflush (stdout);
|
+ fflush (stdout);
|
||||||
+ long iTotalSize = 0;
|
+ long iTotalSize = 0;
|
||||||
+ /* call du -s for each file */
|
+ /* call du -s for each file */
|
||||||
+ /* create command */
|
+ char dcmd[] = "du";
|
||||||
+ char command[1024];
|
+ fp = spawn(dcmd, (char *[]){ dcmd, "-s", (unsigned char *)(size_t)source, NULL });
|
||||||
+ sprintf ( command, "du -s '%s'", source );
|
|
||||||
+ /* TODO: replace all quote signs in file[i] */
|
|
||||||
+
|
|
||||||
+ FILE *fp;
|
|
||||||
+ char output[1024];
|
|
||||||
+
|
|
||||||
+ /* run command */
|
|
||||||
+ fp = popen(command, "r");
|
|
||||||
+ if (fp == NULL || fgets(output, sizeof(output)-1, fp) == NULL) {
|
+ if (fp == NULL || fgets(output, sizeof(output)-1, fp) == NULL) {
|
||||||
+ //printf("failed to run du.\n" );
|
+ printf("failed to run du\r" );
|
||||||
+ }
|
+ }
|
||||||
+ else
|
+ else
|
||||||
+ {
|
+ {
|
||||||
+ /* isolate size */
|
+ /* isolate size */
|
||||||
+ strchr ( output, '\t' )[0] = '\0';
|
+ strchr ( output, '\t' )[0] = '\0';
|
||||||
+ iTotalSize += atol ( output );
|
+ iTotalSize += atol ( output );
|
||||||
+ printf ( "Calculating total size... %ld\r", iTotalSize );
|
+ printf ( "calculating total size... %ld\r", iTotalSize );
|
||||||
+ fflush ( stdout );
|
+ fflush ( stdout );
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ /* close */
|
+ /* close */
|
||||||
+ pclose(fp);
|
+ pclose(fp);
|
||||||
+ g_iTotalSize = iTotalSize;
|
+ g_iTotalSize += iTotalSize;
|
||||||
+ /* END progress mod */
|
|
||||||
+
|
|
||||||
+ }
|
+ }
|
||||||
|
+ /* END progress mod */
|
||||||
+
|
+
|
||||||
bool ok = copy (source, dest, false, x, ©_into_self, &rename_succeeded);
|
bool ok = copy (source, dest, false, x, ©_into_self, &rename_succeeded);
|
||||||
|
|
||||||
|
+ /* BEGIN progress mod */
|
||||||
+ if (progress && (x->rename_errno != 0 && ok)) {
|
+ if (progress && (x->rename_errno != 0 && ok)) {
|
||||||
+ /* BEGIN progress mod */
|
|
||||||
+ /* remove everything */
|
+ /* remove everything */
|
||||||
+ int i;
|
+ int i;
|
||||||
+ int limit = (g_iTotalFiles > 1 ? 6 : 3);
|
+ int limit = (g_iTotalFiles > 1 ? 6 : 3);
|
||||||
+ for ( i = 0; i < limit; i++ )
|
+ if (!rename_succeeded)
|
||||||
+ printf ( "\033[K\n" );
|
+ {
|
||||||
+ printf ( "\r\033[3A" );
|
+ for ( i = 0; i < limit; i++ )
|
||||||
|
+ printf ( "\033[K\n" );
|
||||||
|
+ printf ( "\r\033[3A" );
|
||||||
|
+ }
|
||||||
+
|
+
|
||||||
+ /* save time */
|
+ /* save time */
|
||||||
+ struct timeval end_time;
|
+ struct timeval end_time;
|
||||||
@@ -626,16 +787,32 @@ diff -aur coreutils-9.0/src/mv.c coreutils-9.0-patched/src/mv.c
|
|||||||
+ char s_copy_speed[20];
|
+ char s_copy_speed[20];
|
||||||
+ file_size_format ( s_copy_speed, copy_speed, 1 );
|
+ file_size_format ( s_copy_speed, copy_speed, 1 );
|
||||||
+
|
+
|
||||||
|
+ /* increase counter */
|
||||||
|
+ g_iFilesCopied++;
|
||||||
|
+
|
||||||
+ /* good-bye message */
|
+ /* good-bye message */
|
||||||
+ printf ( "%d files (%s) moved in %.1f seconds (%s/s).\n", g_iFilesCopied, sTotalWritten,
|
+ if ( x->last_file )
|
||||||
+ sec_elapsed, s_copy_speed );
|
+ {
|
||||||
+ /* END progress mod */
|
+ char sFType[20];
|
||||||
|
+ if ( g_iDirectoriesCopied > 0 && g_iDirectoriesCopied == g_iFilesCopied )
|
||||||
|
+ sprintf ( sFType, "%s", "folder(s)" );
|
||||||
|
+ else if ( g_iDirectoriesCopied > 0 && g_iDirectoriesCopied < g_iFilesCopied )
|
||||||
|
+ sprintf ( sFType, "%s", "folder(s)/file(s)" );
|
||||||
|
+ else
|
||||||
|
+ sprintf ( sFType, "%s", "file(s)" );
|
||||||
|
+
|
||||||
|
+ char f_time[20];
|
||||||
|
+ format_time(f_time, sec_elapsed, false);
|
||||||
|
+ printf ( "%d %s (%s) moved in %s (%s/s).\n", g_iFilesCopied, sFType,
|
||||||
|
+ sTotalWritten, f_time, s_copy_speed );
|
||||||
|
+ }
|
||||||
+ }
|
+ }
|
||||||
|
+ /* END progress mod */
|
||||||
+
|
+
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
char const *dir_to_remove;
|
char const *dir_to_remove;
|
||||||
@@ -306,6 +383,7 @@
|
@@ -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\
|
||||||
@@ -643,7 +820,7 @@ diff -aur coreutils-9.0/src/mv.c coreutils-9.0-patched/src/mv.c
|
|||||||
-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 +439,7 @@
|
@@ -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 ();
|
||||||
|
|
||||||
@@ -652,7 +829,7 @@ diff -aur coreutils-9.0/src/mv.c coreutils-9.0-patched/src/mv.c
|
|||||||
!= -1)
|
!= -1)
|
||||||
{
|
{
|
||||||
switch (c)
|
switch (c)
|
||||||
@@ -407,6 +485,9 @@
|
@@ -407,6 +531,9 @@
|
||||||
case 'v':
|
case 'v':
|
||||||
x.verbose = true;
|
x.verbose = true;
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user