[PATCH] makedumpfile: Support line mode terminals

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Michael,

On Mon, 15 Aug 2011 15:24:26 +0200
Michael Holzheu <holzheu at linux.vnet.ibm.com> wrote:
>
> From: Michael Holzheu <holzheu at linux.vnet.ibm.com>
> 
> 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 %]
> 
> Signed-off-by: Michael Holzheu <holzheu at linux.vnet.ibm.com>

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

Acked-by: Ken'ichi Ohmichi <oomichi at mxs.nes.nec.co.jp>


Thanks
Ken'ichi Ohmichi

> ---
>  makedumpfile.c |   22 +++++++++++++++++++---
>  1 file changed, 19 insertions(+), 3 deletions(-)
> 
> --- a/makedumpfile.c
> +++ b/makedumpfile.c
> @@ -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));
> 
> 



[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux