Subject: [PATCH] Support line mode terminals From: Michael Holzheu On S390 we have line mode terminals that do not have the possibility 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 data : [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 %] git commit: 714d177d594703adadd48cf393c2a3aa03e928ad Signed-off-by: Michael Holzheu --- makedumpfile-1.3.5/makedumpfile.c | 11 +++++++++-- makedumpfile-1.3.5/makedumpfile.h | 1 + makedumpfile-1.3.5/s390x.c | 5 +++++ 3 files changed, 15 insertions(+), 2 deletions(-) --- a/makedumpfile-1.3.5/makedumpfile.c +++ b/makedumpfile-1.3.5/makedumpfile.c @@ -28,6 +28,7 @@ struct DumpInfo *info = NULL; char filename_stdout[] = FILENAME_STDOUT; int message_level; +int flag_ignore_r_char; /* 0: '\r' is effective. 1: not effective. */ /* * Forward declarations @@ -5611,8 +5612,14 @@ print_progress(const char *msg, unsigned } else progress = 100; - PROGRESS_MSG("\r"); - PROGRESS_MSG("%-" PROGRESS_MAXLEN "s: [%3d %%] ", msg, progress); + if (flag_ignore_r_char) { + PROGRESS_MSG("%-" PROGRESS_MAXLEN "s: [%3d %%]\n", + msg, progress); + } else { + PROGRESS_MSG("\r"); + PROGRESS_MSG("%-" PROGRESS_MAXLEN "s: [%3d %%] ", + msg, progress); + } } unsigned long long --- a/makedumpfile-1.3.5/makedumpfile.h +++ b/makedumpfile-1.3.5/makedumpfile.h @@ -169,6 +169,7 @@ isAnon(unsigned long mapping) #define ML_PRINT_DEBUG_MSG (0x008) /* Print the debugging message */ #define ML_PRINT_REPORT_MSG (0x010) /* Print the report message */ extern int message_level; +extern int flag_ignore_r_char; #define MSG(x...) \ do { \ --- a/makedumpfile-1.3.5/s390x.c +++ b/makedumpfile-1.3.5/s390x.c @@ -61,6 +61,11 @@ int get_machdep_info_s390x(void) { unsigned long vmlist, vmalloc_start; + char *term_str = getenv("TERM"); + + if (term_str && strcmp(term_str, "dumb") == 0) + /* '\r' control character is ignored on "dumb" terminal. */ + flag_ignore_r_char = 1; info->section_size_bits = _SECTION_SIZE_BITS; info->max_physmem_bits = _MAX_PHYSMEM_BITS;