Blame SOURCES/cryptsetup-1.7.6-cryptsetup-reencrypt-progress-frequency-parameter.patch

00122a
diff -rupN cryptsetup-1.7.4.bcp/man/cryptsetup-reencrypt.8 cryptsetup-1.7.4/man/cryptsetup-reencrypt.8
00122a
--- cryptsetup-1.7.4.bcp/man/cryptsetup-reencrypt.8	2017-10-18 11:39:01.697902733 +0200
00122a
+++ cryptsetup-1.7.4/man/cryptsetup-reencrypt.8	2017-10-18 13:31:15.944930492 +0200
00122a
@@ -38,7 +38,7 @@ To start (or continue) re-encryption for
00122a
 \-\-device-size, \-\-hash, \-\-iter-time, \-\-use-random | \-\-use-urandom,
00122a
 \-\-keep-key, \-\-key-size, \-\-key-file, \-\-key-slot, \-\-keyfile-offset,
00122a
 \-\-keyfile-size, \-\-tries, \-\-use-directio, \-\-use-fsync, \-\-verbose, \-\-write-log,
00122a
-\-\-uuid]
00122a
+\-\-uuid, \-\-progress-frequency]
00122a
 
00122a
 To encrypt data on (not yet encrypted) device, use \fI\-\-new\fR with combination
00122a
 with \fI\-\-reduce-device-size\fR.
00122a
@@ -190,6 +190,9 @@ of the interrupted decryption process.
00122a
 .B "\-\-batch-mode, \-q"
00122a
 Suppresses all warnings and reencryption progress output.
00122a
 .TP
00122a
+.B "\-\-progress-frequency <seconds>"
00122a
+Print separate line every <seconds> with reencryption progress.
00122a
+.TP
00122a
 .B "\-\-version"
00122a
 Show the program version.
00122a
 .SH RETURN CODES
00122a
diff -rupN cryptsetup-1.7.4.bcp/src/cryptsetup_reencrypt.c cryptsetup-1.7.4/src/cryptsetup_reencrypt.c
00122a
--- cryptsetup-1.7.4.bcp/src/cryptsetup_reencrypt.c	2017-10-18 11:39:01.697902733 +0200
00122a
+++ cryptsetup-1.7.4/src/cryptsetup_reencrypt.c	2017-10-18 15:10:24.219013071 +0200
00122a
@@ -51,6 +51,7 @@ static int opt_key_size = 0;
00122a
 static int opt_new = 0;
00122a
 static int opt_keep_key = 0;
00122a
 static int opt_decrypt = 0;
00122a
+static int opt_progress_frequency = 0;
00122a
 
00122a
 static const char *opt_reduce_size_str = NULL;
00122a
 static uint64_t opt_reduce_size = 0;
00122a
@@ -665,10 +666,18 @@ static void print_progress(struct reenc_
00122a
 {
00122a
 	unsigned long long mbytes, eta;
00122a
 	struct timeval now_time;
00122a
-	double tdiff, mib;
00122a
+	double tdiff, mib, frequency;
00122a
+	char *eol = "";
00122a
 
00122a
 	gettimeofday(&now_time, NULL);
00122a
-	if (!final && time_diff(rc->end_time, now_time) < 0.5)
00122a
+	if (opt_progress_frequency)
00122a
+		frequency = (double)opt_progress_frequency;
00122a
+	else
00122a
+		frequency = 0.5;
00122a
+	if (final || opt_progress_frequency)
00122a
+		eol = "\n";
00122a
+
00122a
+	if (!final && time_diff(rc->end_time, now_time) < frequency)
00122a
 		return;
00122a
 
00122a
 	rc->end_time = now_time;
00122a
@@ -689,12 +698,12 @@ static void print_progress(struct reenc_
00122a
 	eta = (unsigned long long)(rc->device_size / 1024 / 1024 / mib - tdiff);
00122a
 
00122a
 	/* vt100 code clear line */
00122a
-	log_err("\33[2K\r");
00122a
+	if (!opt_progress_frequency)
00122a
+		log_err("\33[2K\r");
00122a
 	log_err(_("Progress: %5.1f%%, ETA %02llu:%02llu, "
00122a
 		"%4llu MiB written, speed %5.1f MiB/s%s"),
00122a
 		(double)bytes / rc->device_size * 100,
00122a
-		eta / 60, eta % 60, mbytes, mib,
00122a
-		final ? "\n" :"");
00122a
+		eta / 60, eta % 60, mbytes, mib, eol);
00122a
 }
00122a
 
00122a
 static ssize_t read_buf(int fd, void *buf, size_t count)
00122a
@@ -1316,6 +1325,7 @@ int main(int argc, const char **argv)
00122a
 		{ "key-file",          'd',  POPT_ARG_STRING, &opt_key_file,            0, N_("Read the key from a file."), NULL },
00122a
 		{ "iter-time",         'i',  POPT_ARG_INT, &opt_iteration_time,         0, N_("PBKDF2 iteration time for LUKS (in ms)"), N_("msecs") },
00122a
 		{ "batch-mode",        'q',  POPT_ARG_NONE, &opt_batch_mode,            0, N_("Do not ask for confirmation"), NULL },
00122a
+		{ "progress-frequency",'\0', POPT_ARG_INT, &opt_progress_frequency,     0, N_("Progress line update (in seconds)"), N_("secs") },
00122a
 		{ "tries",             'T',  POPT_ARG_INT, &opt_tries,                  0, N_("How often the input of the passphrase can be retried"), NULL },
00122a
 		{ "use-random",        '\0', POPT_ARG_NONE, &opt_random,                0, N_("Use /dev/random for generating volume key."), NULL },
00122a
 		{ "use-urandom",       '\0', POPT_ARG_NONE, &opt_urandom,               0, N_("Use /dev/urandom for generating volume key."), NULL },