diff --git a/man/cryptsetup-reencrypt.8 b/man/cryptsetup-reencrypt.8 index c44ff21e..e08c44b5 100644 --- a/man/cryptsetup-reencrypt.8 +++ b/man/cryptsetup-reencrypt.8 @@ -40,7 +40,7 @@ To start (or continue) re-encryption for use: \-\-device-size, \-\-hash, \-\-iter-time, \-\-use-random | \-\-use-urandom, \-\-keep-key, \-\-key-size, \-\-key-file, \-\-key-slot, \-\-keyfile-offset, \-\-keyfile-size, \-\-tries, \-\-use-directio, \-\-use-fsync, \-\-verbose, \-\-write-log, -\-\-uuid] +\-\-uuid, \-\-progress-frequency] To encrypt data on (not yet encrypted) device, use \fI\-\-new\fR with combination with \fI\-\-reduce-device-size\fR. @@ -192,6 +192,9 @@ of the interrupted decryption process. .B "\-\-batch-mode, \-q" Suppresses all warnings and reencryption progress output. .TP +.B "\-\-progress-frequency " +Print separate line every with reencryption progress. +.TP .B "\-\-version" Show the program version. .SH RETURN CODES diff --git a/man/cryptsetup.8 b/man/cryptsetup.8 index cfe90181..75ad1cac 100644 --- a/man/cryptsetup.8 +++ b/man/cryptsetup.8 @@ -924,6 +924,9 @@ Suppresses all confirmation questions. Use with care! If the \-y option is not specified, this option also switches off the passphrase verification for \fIluksFormat\fR. .TP +.B "\-\-progress-frequency " +Print separate line every with wipe progress. +.TP .B "\-\-timeout, \-t " The number of seconds to wait before timeout on passphrase input via terminal. It is relevant every time a passphrase is asked, diff --git a/man/integritysetup.8 b/man/integritysetup.8 index 46d3460c..96e36c85 100644 --- a/man/integritysetup.8 +++ b/man/integritysetup.8 @@ -20,7 +20,8 @@ Integritysetup supports these operations: Formats (calculates space and dm-integrity superblock and wipes the device). \fB\fR can be [\-\-batch\-mode, \-\-no\-wipe, \-\-journal\-size, \-\-interleave\-sectors, -\-\-tag\-size, \-\-integrity, \-\-integrity\-key\-size, \-\-integrity\-key\-file, \-\-sector\-size] +\-\-tag\-size, \-\-integrity, \-\-integrity\-key\-size, \-\-integrity\-key\-file, \-\-sector\-size, +\-\-progress-frequency] .PP \fIopen\fR @@ -64,6 +65,9 @@ Show the program version. .B "\-\-batch\-mode" Do not ask for confirmation. .TP +.B "\-\-progress-frequency " +Print separate line every with wipe progress. +.TP .B "\-\-no\-wipe" Do not wipe the device after format. A device that is not initially wiped will contain invalid checksums. .TP diff --git a/src/cryptsetup.c b/src/cryptsetup.c index 78f5ab80..547b9860 100644 --- a/src/cryptsetup.c +++ b/src/cryptsetup.c @@ -2020,6 +2020,7 @@ int main(int argc, const char **argv) { "readonly", 'r', POPT_ARG_NONE, &opt_readonly, 0, N_("Create a readonly mapping"), NULL }, { "batch-mode", 'q', POPT_ARG_NONE, &opt_batch_mode, 0, N_("Do not ask for confirmation"), NULL }, { "timeout", 't', POPT_ARG_INT, &opt_timeout, 0, N_("Timeout for interactive passphrase prompt (in seconds)"), N_("secs") }, + { "progress-frequency",'\0', POPT_ARG_INT, &opt_progress_frequency, 0, N_("Progress line update (in seconds)"), N_("secs") }, { "tries", 'T', POPT_ARG_INT, &opt_tries, 0, N_("How often the input of the passphrase can be retried"), NULL }, { "align-payload", '\0', POPT_ARG_INT, &opt_align_payload, 0, N_("Align payload at sector boundaries - for luksFormat"), N_("SECTORS") }, { "header-backup-file",'\0', POPT_ARG_STRING, &opt_header_backup_file, 0, N_("File with LUKS header and keyslots backup."), NULL }, diff --git a/src/cryptsetup.h b/src/cryptsetup.h index bebd693e..40bc050a 100644 --- a/src/cryptsetup.h +++ b/src/cryptsetup.h @@ -58,6 +58,8 @@ extern int opt_debug; extern int opt_verbose; extern int opt_batch_mode; extern int opt_force_password; +extern int opt_progress_frequency; + /* Common tools */ void clogger(struct crypt_device *cd, int level, const char *file, int line, diff --git a/src/cryptsetup_reencrypt.c b/src/cryptsetup_reencrypt.c index 22e1692a..de38afd8 100644 --- a/src/cryptsetup_reencrypt.c +++ b/src/cryptsetup_reencrypt.c @@ -1267,6 +1267,7 @@ int main(int argc, const char **argv) { "key-file", 'd', POPT_ARG_STRING, &opt_key_file, 0, N_("Read the key from a file."), NULL }, { "iter-time", 'i', POPT_ARG_INT, &opt_iteration_time, 0, N_("PBKDF2 iteration time for LUKS (in ms)"), N_("msecs") }, { "batch-mode", 'q', POPT_ARG_NONE, &opt_batch_mode, 0, N_("Do not ask for confirmation"), NULL }, + { "progress-frequency",'\0', POPT_ARG_INT, &opt_progress_frequency, 0, N_("Progress line update (in seconds)"), N_("secs") }, { "tries", 'T', POPT_ARG_INT, &opt_tries, 0, N_("How often the input of the passphrase can be retried"), NULL }, { "use-random", '\0', POPT_ARG_NONE, &opt_random, 0, N_("Use /dev/random for generating volume key."), NULL }, { "use-urandom", '\0', POPT_ARG_NONE, &opt_urandom, 0, N_("Use /dev/urandom for generating volume key."), NULL }, diff --git a/src/integritysetup.c b/src/integritysetup.c index 6eae2fad..0389d05c 100644 --- a/src/integritysetup.c +++ b/src/integritysetup.c @@ -483,6 +483,7 @@ int main(int argc, const char **argv) { "verbose", 'v', POPT_ARG_NONE, &opt_verbose, 0, N_("Shows more detailed error messages"), NULL }, { "debug", '\0', POPT_ARG_NONE, &opt_debug, 0, N_("Show debug messages"), NULL }, { "batch-mode", 'q', POPT_ARG_NONE, &opt_batch_mode, 0, N_("Do not ask for confirmation"), NULL }, + { "progress-frequency", '\0', POPT_ARG_INT, &opt_progress_frequency, 0, N_("Progress line update (in seconds)"), N_("secs") }, { "no-wipe", '\0', POPT_ARG_NONE, &opt_no_wipe, 0, N_("Do not wipe device after format"), NULL }, { "journal-size", 'j', POPT_ARG_STRING,&opt_journal_size_str, 0, N_("Journal size"), N_("bytes") }, diff --git a/src/utils_tools.c b/src/utils_tools.c index 8176c9f3..379dd977 100644 --- a/src/utils_tools.c +++ b/src/utils_tools.c @@ -28,6 +28,7 @@ int opt_verbose = 0; int opt_debug = 0; int opt_batch_mode = 0; +int opt_progress_frequency = 0; /* interrupt handling */ volatile int quit = 0; @@ -336,9 +337,10 @@ static double time_diff(struct timeval *start, struct timeval *end) + (end->tv_usec - start->tv_usec) / 1E6; } -// FIXME: detect terminal type void tools_clear_line(void) { + if (opt_progress_frequency) + return; /* vt100 code clear line */ log_std("\33[2K\r"); } @@ -348,8 +350,9 @@ void tools_time_progress(uint64_t device_size, uint64_t bytes, { struct timeval now_time; unsigned long long mbytes, eta; - double tdiff, mib; + double tdiff, mib, frequency; int final = (bytes == device_size); + char *eol; if (opt_batch_mode) return; @@ -361,7 +364,15 @@ void tools_time_progress(uint64_t device_size, uint64_t bytes, return; } - if (!final && time_diff(end_time, &now_time) < 0.5) + if (opt_progress_frequency) { + frequency = (double)opt_progress_frequency; + eol = "\n"; + } else { + frequency = 0.5; + eol = ""; + } + + if (!final && time_diff(end_time, &now_time) < frequency) return; *end_time = now_time; @@ -388,9 +399,9 @@ void tools_time_progress(uint64_t device_size, uint64_t bytes, mbytes, mib); else log_std("Progress: %5.1f%%, ETA %02llu:%02llu, " - "%4llu MiB written, speed %5.1f MiB/s", + "%4llu MiB written, speed %5.1f MiB/s%s", (double)bytes / device_size * 100, - eta / 60, eta % 60, mbytes, mib); + eta / 60, eta % 60, mbytes, mib, eol); fflush(stdout); }