Skip to contentSkip to conversation

makedumpfile: Support line mode terminals

PATCH In review Michael Holzheu 2 participants 2 messages Aug 15, 2011 – Aug 19, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 makedumpfile: Support line mode terminals

From: Michael Holzheu <[email protected]>

On S390 we have line mode terminals that do not have the ability to position the cursor. When using kdump the output of makedumpfile will be shown on such terminals. Currently the output looks very strange because the '\r' control character is ignored. It looks like the following:

Checking for memory holes : [ 0 %] Checking for memory holes
: [100 %] Copying data : [ 33 %] Copying data
: [ 65 %] Copying data : [ 96 %] Copying d
ata : [100 %]

For those line mode terminals the TERM environment variable is set to "dumb". With this patch makedumpfile checks the TERM variable and in case of "dumb" instead of using '\r' each progress message is printed into a separate line. The output will then look like the following:

Checking for memory holes          : [  0 %]
Checking for memory holes          : [100 %]
Copying data                       : [ 11 %]
Copying data                       : [ 44 %]
Copying data                       : [ 75 %]
Copying data                       : [100 %]
---
 makedumpfile.c |   22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)
makedumpfile.c +19 -3
@@ -29,6 +29,7 @@ struct DumpInfo		*info = NULL;
 
 char filename_stdout[] = FILENAME_STDOUT;
 int message_level;
+static int dumb_term;
 
 /*
  * Forward declarations
@@ -5661,9 +5662,14 @@ print_progress(const char *msg, unsigned
 		progress = current * 100 / end;
 	} else
 		progress = 100;
-
-	PROGRESS_MSG("\r");
-	PROGRESS_MSG("%-" PROGRESS_MAXLEN "s: [%3d %%] ", msg, progress);
+	if (dumb_term) {
+		PROGRESS_MSG("%-" PROGRESS_MAXLEN "s: [%3d %%]\n",
+			     msg, progress);
+	} else {
+		PROGRESS_MSG("\r");
+		PROGRESS_MSG("%-" PROGRESS_MAXLEN "s: [%3d %%] ",
+			     msg, progress);
+	}
 }
 
 unsigned long long
@@ -7825,11 +7831,21 @@ static struct option longopts[] = {
 	{0, 0, 0, 0}
 };
 
+static void setup_term(void)
+{
+	char *term_str = getenv("TERM");
+
+	if (term_str && strcmp(term_str, "dumb") == 0)
+		dumb_term = 1;
+}
+
 int
 main(int argc, char *argv[])
 {
 	int i, opt, flag_debug = FALSE;
 
+	setup_term();
+
 	if ((info = calloc(1, sizeof(struct DumpInfo))) == NULL) {
 		ERRMSG("Can't allocate memory for the pagedesc cache. %s.\n",
 		    strerror(errno));

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

Acked-by on v1 1/1
#1 lore raw

Hi Michael,

Quoted 18 lines · On Mon, 15 Aug 2011 15:24:26 +0200 Michael Holzheu…

From: Michael Holzheu <[email protected]>

On S390 we have line mode terminals that do not have the ability to position the cursor. When using kdump the output of makedumpfile will be shown on such terminals. Currently the output looks very strange because the '\r' control character is ignored. It looks like the following:

Checking for memory holes : [ 0 %] Checking for memory holes
: [100 %] Copying data : [ 33 %] Copying data
: [ 65 %] Copying data : [ 96 %] Copying d
ata : [100 %]

For those line mode terminals the TERM environment variable is set to "dumb". With this patch makedumpfile checks the TERM variable and in case of "dumb" instead of using '\r' each progress message is printed into a separate line. The output will then look like the following:

Quoted 8 lines
Checking for memory holes          : [  0 %]
Checking for memory holes          : [100 %]
Copying data                       : [ 11 %]
Copying data                       : [ 44 %]
Copying data                       : [ 75 %]
Copying data                       : [100 %]

Thank you for the patch, and it has been merged to devel tree.

http://makedumpfile.git.sourceforge.net/git/gitweb.cgi?p=makedumpfile/makedumpfile;a=commit;h=4b4e1625a5ebe37cb0991fe1628f19bca2b1502f

Thanks
Ken'ichi Ohmichi

Quoted 46 lines
---
 makedumpfile.c |   22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)
makedumpfile.c +17 -3
@@ -29,6 +29,7 @@ struct DumpInfo		*info = NULL;
 
 char filename_stdout[] = FILENAME_STDOUT;
 int message_level;
+static int dumb_term;
 
 /*
  * Forward declarations
@@ -5661,9 +5662,14 @@ print_progress(const char *msg, unsigned
 		progress = current * 100 / end;
 	} else
 		progress = 100;
-
-	PROGRESS_MSG("\r");
-	PROGRESS_MSG("%-" PROGRESS_MAXLEN "s: [%3d %%] ", msg, progress);
+	if (dumb_term) {
+		PROGRESS_MSG("%-" PROGRESS_MAXLEN "s: [%3d %%]\n",
+			     msg, progress);
+	} else {
+		PROGRESS_MSG("\r");
+		PROGRESS_MSG("%-" PROGRESS_MAXLEN "s: [%3d %%] ",
+			     msg, progress);
+	}
 }
 
 unsigned long long
@@ -7825,11 +7831,21 @@ static struct option longopts[] = {
 	{0, 0, 0, 0}
 };
 
+static void setup_term(void)
+{
+	char *term_str = getenv("TERM");
+
+	if (term_str && strcmp(term_str, "dumb") == 0)
+		dumb_term = 1;
+}
+

makedumpfile.c static struct option longopts[] = { · line 7851

Quoted 10 lines
makedumpfile.c +2 -0
 int
 main(int argc, char *argv[])
 {
 	int i, opt, flag_debug = FALSE;
 
+	setup_term();
+
 	if ((info = calloc(1, sizeof(struct DumpInfo))) == NULL) {
 		ERRMSG("Can't allocate memory for the pagedesc cache. %s.\n",
 		    strerror(errno));

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec