Blob Blame History Raw
From 6f3e75a558ed50d6ff0b42e3f61c099b2005b7bb Mon Sep 17 00:00:00 2001
From: Julien Thierry <jthierry@redhat.com>
Date: Tue, 24 Nov 2020 10:45:25 +0000
Subject: [PATCH] [PATCH 2/2] Add shorthand --show-stats option to show report
 stats

Provide shorthand --show-stats option to enable report messages
without needing to set a particular value for message-level.

Signed-off-by: Julien Thierry <jthierry@redhat.com>
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
---
 makedumpfile.8 | 5 +++++
 makedumpfile.c | 9 ++++++++-
 makedumpfile.h | 1 +
 print_info.c   | 7 ++++++-
 4 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/makedumpfile-1.6.8/makedumpfile.8 b/makedumpfile-1.6.8/makedumpfile.8
index 5e902cd..dcca2dd 100644
--- a/makedumpfile-1.6.8/makedumpfile.8
+++ b/makedumpfile-1.6.8/makedumpfile.8
@@ -643,6 +643,11 @@ Do not write the output dump file while still performing operations specified
 by other options.
 This option cannot be used with the --dump-dmesg, --reassemble and -g options.
 
+.TP
+\fB\-\-show-stats\fR
+Display report messages. This is an alternative to enabling bit 4 in the level
+provided to --message-level.
+
 .SH ENVIRONMENT VARIABLES
 
 .TP 8
diff --git a/makedumpfile-1.6.8/makedumpfile.c b/makedumpfile-1.6.8/makedumpfile.c
index 8c80c49..ba0003a 100644
--- a/makedumpfile-1.6.8/makedumpfile.c
+++ b/makedumpfile-1.6.8/makedumpfile.c
@@ -11540,13 +11540,14 @@ static struct option longopts[] = {
 	{"num-threads", required_argument, NULL, OPT_NUM_THREADS},
 	{"check-params", no_argument, NULL, OPT_CHECK_PARAMS},
 	{"dry-run", no_argument, NULL, OPT_DRY_RUN},
+	{"show-stats", no_argument, NULL, OPT_SHOW_STATS},
 	{0, 0, 0, 0}
 };
 
 int
 main(int argc, char *argv[])
 {
-	int i, opt, flag_debug = FALSE;
+	int i, opt, flag_debug = FALSE, flag_show_stats = FALSE;
 
 	if ((info = calloc(1, sizeof(struct DumpInfo))) == NULL) {
 		ERRMSG("Can't allocate memory for the pagedesc cache. %s.\n",
@@ -11709,6 +11710,9 @@ main(int argc, char *argv[])
 		case OPT_DRY_RUN:
 			info->flag_dry_run = TRUE;
 			break;
+		case OPT_SHOW_STATS:
+			flag_show_stats = TRUE;
+			break;
 		case '?':
 			MSG("Commandline parameter is invalid.\n");
 			MSG("Try `makedumpfile --help' for more information.\n");
@@ -11718,6 +11722,9 @@ main(int argc, char *argv[])
 	if (flag_debug)
 		message_level |= ML_PRINT_DEBUG_MSG;
 
+	if (flag_show_stats)
+		message_level |= ML_PRINT_REPORT_MSG;
+
 	if (info->flag_check_params)
 		/* suppress debugging messages */
 		message_level = DEFAULT_MSG_LEVEL;
diff --git a/makedumpfile-1.6.8/makedumpfile.h b/makedumpfile-1.6.8/makedumpfile.h
index 4c4222c..2fcb62e 100644
--- a/makedumpfile-1.6.8/makedumpfile.h
+++ b/makedumpfile-1.6.8/makedumpfile.h
@@ -2427,6 +2427,7 @@ struct elf_prstatus {
 #define OPT_PARTIAL_DMESG       OPT_START+17
 #define OPT_CHECK_PARAMS        OPT_START+18
 #define OPT_DRY_RUN             OPT_START+19
+#define OPT_SHOW_STATS          OPT_START+20
 
 /*
  * Function Prototype.
diff --git a/makedumpfile-1.6.8/print_info.c b/makedumpfile-1.6.8/print_info.c
index d2b0cb7..ad4184e 100644
--- a/makedumpfile-1.6.8/print_info.c
+++ b/makedumpfile-1.6.8/print_info.c
@@ -309,7 +309,12 @@ print_usage(void)
 	MSG("      vmcoreinfo. So currently /proc/kcore need be specified explicitly.\n");
 	MSG("\n");
 	MSG("  [--dry-run]:\n");
-	MSG("      This option runs makedumpfile without writting output dump file.\n");
+	MSG("      Do not write the output dump file while still performing operations specified\n");
+	MSG("      by other options.  This option cannot be used with --dump-dmesg, --reassemble\n");
+	MSG("      and -g options.\n");
+	MSG("\n");
+	MSG("  [--show-stats]:\n");
+	MSG("      Set message-level to print report messages\n");
 	MSG("\n");
 	MSG("  [-D]:\n");
 	MSG("      Print debugging message.\n");
-- 
2.29.2