[PATCH] makedumpfile: Fix dmesg format after crash utility

Petr Tesarik ptesarik at suse.cz
Fri Aug 29 01:21:51 PDT 2014


On Fri, 29 Aug 2014 01:43:31 +0000
Atsushi Kumagai <kumagai-atsushi at mxc.nes.nec.co.jp> wrote:

> Hello,

Hello Kumagai-san,

> I made a trivial patch for v1.5.7.
> This isn't essential but it's better than nothing.
>[...]
> diff --git a/makedumpfile.c b/makedumpfile.c
> index b4b6eca..632daba 100644
> --- a/makedumpfile.c
> +++ b/makedumpfile.c
> @@ -3950,6 +3950,7 @@ dump_log_entry(char *logptr, int fp)
>  {
>  	char *msg, *p, *bufp;
>  	unsigned int i, text_len;
> +	unsigned int indent_len;
>  	unsigned long long ts_nsec;
>  	char buf[BUFSIZE];
>  	ulonglong nanos;
> @@ -3965,6 +3966,7 @@ dump_log_entry(char *logptr, int fp)
>  
>  	bufp = buf;
>  	bufp += sprintf(buf, "[%5lld.%06ld] ", nanos, rem/1000);
> +	indent_len = strlen(buf);
>  
>  	for (i = 0, p = msg; i < text_len; i++, p++) {
>  		/* 6bytes = "\\x%02x" + '\n' + '\0' */
> @@ -3974,7 +3976,9 @@ dump_log_entry(char *logptr, int fp)
>  			bufp = buf;
>  		}
>  
> -		if (isprint(*p) || isspace(*p))
> +		if (*p == '\n')
> +			bufp += sprintf(bufp, "\n%-*s", indent_len, "");
> +		else if (isprint(*p) || isspace(*p))

If you do this, you'll have to adjust the condition for growing the buffer above:

	if (bufp - buf >= sizeof(buf) - 6) {

Let me send a cleanup patch for the "magic constant", which was never a
good idea, it seems.

Petr Tesarik



More information about the kexec mailing list