From e48de7c114fc724a6c1e45fd8716dc6111d01372 Mon Sep 17 00:00:00 2001 From: Andrey Rys Date: Sun, 28 Nov 2021 14:15:49 +0100 Subject: [PATCH] -O finished: prepend "finished: " marker when tfcrypt done (useful for logs). --- VERSION | 2 +- tfc_error.c | 1 + tfc_signal.c | 12 ++++++------ tfc_vars.c | 2 +- tfcrypt.c | 2 ++ tfcrypt.h | 2 +- 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/VERSION b/VERSION index abac1ea..21e72e8 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -47 +48 diff --git a/tfc_error.c b/tfc_error.c index d74fd56..d95f420 100644 --- a/tfc_error.c +++ b/tfc_error.c @@ -316,6 +316,7 @@ void usage(void) tfc_say(" statless: emit less information in status line (only processed data)."); tfc_say(" norepeat: do not ask for any possible password confirmations."); tfc_say(" showsecrets: show passwords in plaintext instead of masking them."); + tfc_say(" finished: add \"finished\" word before status line when work is finished."); tfc_say(" prompt=str: set main password prompts to this string."); tfc_say(" macprompt=str: set MAC password prompts to this string."); tfc_say(" shorthex: with -H, do not print printable characters, dump only hex string."); diff --git a/tfc_signal.c b/tfc_signal.c index 4c91819..b0d6e48 100644 --- a/tfc_signal.c +++ b/tfc_signal.c @@ -95,28 +95,28 @@ void print_crypt_status(int signal) else inplace = ""; if (do_less_stats == YES) { - tfc_nfsay(stderr, "%s%s:" + tfc_nfsay(stderr, "%s%s%s:" " %s %.2f%s," " %.2f%s B/s @%s", - inplace, progname, + inplace, (last && show_when_done) ? "finished: " : "", progname, oper_mode, human_totalproc_dst, tfc_getscale(dst_scale_idx), human_wr_speed, tfc_getscale(wr_speed_scale), tfc_format_time(total_time)); } else { - if (ctr_mode <= TFC_MODE_PLAIN) tfc_nfsay(stderr, "%s%s: read: %llu (%.2f%s)," + if (ctr_mode <= TFC_MODE_PLAIN) tfc_nfsay(stderr, "%s%s%s: read: %llu (%.2f%s)," " %s %llu (%.2f%s) bytes," " (%llu (%.2f%s) B/s), time %s", - inplace, progname, + inplace, (last && show_when_done) ? "finished: " : "", progname, total_processed_src, human_totalproc_src, tfc_getscale(src_scale_idx), oper_mode, total_processed_dst, human_totalproc_dst, tfc_getscale(dst_scale_idx), wr_speed, human_wr_speed, tfc_getscale(wr_speed_scale), tfc_format_time(total_time)); - else tfc_nfsay(stderr, "%s%s: read: %llu (%.2f%s)," + else tfc_nfsay(stderr, "%s%s%s: read: %llu (%.2f%s)," " %s %s %llu (%.2f%s) bytes," " written %llu (%.2f%s) bytes," " (%llu (%.2f%s) B/s), time %s", - inplace, progname, + inplace, (last && show_when_done) ? "finished: " : "", progname, total_processed_src, human_totalproc_src, tfc_getscale(src_scale_idx), tfc_modename(ctr_mode), oper_mode, total_processed_dst, human_totalproc_dst, tfc_getscale(dst_scale_idx), diff --git a/tfc_vars.c b/tfc_vars.c index 359c7e1..0148f77 100644 --- a/tfc_vars.c +++ b/tfc_vars.c @@ -64,7 +64,7 @@ int counter_opt, mackey_opt, do_mac, do_outfmt = TFC_OUTFMT_B64, rawkey; int idx, write_flags; tfc_yesno catch_all_errors, ignore_seek_errors, password, overwrite_source, do_fsync, do_pad, do_ftrunc = TFC_NO_FTRUNC; tfc_yesno do_preserve_time, do_stats_in_gibs, do_statline_dynamic = YES, do_less_stats; -tfc_yesno no_repeat, do_full_hexdump = YES, verbose, statline_was_shown, show_secrets; +tfc_yesno no_repeat, do_full_hexdump = YES, verbose, statline_was_shown, show_secrets, show_when_done; char *srcfname = TFC_STDIN_NAME, *dstfname = TFC_STDOUT_NAME, *do_mac_file, *counter_file, *sksum_hashlist_file; char *saltf, *genkeyf, *mackeyf, *tweakf; char *pw_prompt, *mac_pw_prompt; diff --git a/tfcrypt.c b/tfcrypt.c index 6b9055f..aa7db33 100644 --- a/tfcrypt.c +++ b/tfcrypt.c @@ -332,6 +332,8 @@ _baddfname: do_full_key = YES; else if (!strcmp(s, "showsecrets")) show_secrets = YES; + else if (!strcmp(s, "finished")) + show_when_done = YES; else if (!strncmp(s, "logfile", 7) && *(s+7) == '=') open_log(s+8); else if (!strncmp(s, "iobs", 4) && *(s+4) == '=') { diff --git a/tfcrypt.h b/tfcrypt.h index 67b4956..1b5f811 100644 --- a/tfcrypt.h +++ b/tfcrypt.h @@ -158,7 +158,7 @@ extern int counter_opt, mackey_opt, do_mac, do_outfmt, rawkey; extern int idx, write_flags; extern tfc_yesno catch_all_errors, ignore_seek_errors, password, overwrite_source, do_fsync, do_pad, do_ftrunc; extern tfc_yesno do_preserve_time, do_stats_in_gibs, do_statline_dynamic, do_less_stats; -extern tfc_yesno no_repeat, do_full_hexdump, verbose, statline_was_shown, show_secrets; +extern tfc_yesno no_repeat, do_full_hexdump, verbose, statline_was_shown, show_secrets, show_when_done; extern char *srcfname, *dstfname, *do_mac_file, *counter_file, *sksum_hashlist_file; extern char *saltf, *genkeyf, *mackeyf, *tweakf; extern char *pw_prompt, *mac_pw_prompt; -- 2.31.1