[PATCH][v2] lib: fwts_dump: add cpuinfo dump

Colin Ian King colin.king at canonical.com
Wed Jun 18 07:16:05 UTC 2014


On 17/06/14 20:52, Alex Hung wrote:
> When running fwts-live, it is sometimes difficult to analyze
> results without cpu information. This patch dump cpuinfo
> from /proc/cpuinfo.
> 
> Signed-off-by: Alex Hung <alex.hung at canonical.com>
> ---
>  src/lib/src/fwts_dump.c | 32 ++++++++++++++++++++++++++++++++
>  1 file changed, 32 insertions(+)
> 
> diff --git a/src/lib/src/fwts_dump.c b/src/lib/src/fwts_dump.c
> index 8c59f57..33156c0 100644
> --- a/src/lib/src/fwts_dump.c
> +++ b/src/lib/src/fwts_dump.c
> @@ -222,6 +222,33 @@ static int dump_readme(void)
>  }
>  
>  /*
> + *  dump_cpuinfo()
> + *	read cpuinfo, dump to path/filename
> + */
> +static int dump_cpuinfo(void)
> +{
> +	FILE *source, *target;
> +	char buffer[1024];
> +	size_t bytes;
> +
> +	if ((source = fopen("/proc/cpuinfo", "r")) == NULL)
> +		return FWTS_ERROR;
> +
> +	if ((target = fopen("cpuinfo.log", "w")) == NULL) {
> +		fclose(source);
> +		return FWTS_ERROR;
> +	}
> +
> +	while (0 < (bytes = fread(buffer, 1, sizeof(buffer), source)))
> +		fwrite(buffer, 1, bytes, target);
> +
> +	fclose(source);
> +	fclose(target);
> +
> +	return FWTS_OK;
> +}
> +
> +/*
>   *  fwts_dump_info()
>   *	dump various system specific information:
>   *	kernel log, dmidecode output, lspci output,
> @@ -273,5 +300,10 @@ int fwts_dump_info(fwts_framework *fw)
>  	} else
>  		fprintf(stderr, "Need root privilege to dump ACPI tables.\n");
>  
> +	if (dump_cpuinfo() != FWTS_OK)
> +		fprintf(stderr, "Failed to dump cpuinfo.\n");
> +	else
> +		printf("Dumping cpuinfo to cpuinfo.log\n");
> +
>  	return FWTS_OK;
>  }
> 
Thanks Alex, lets take this patch.

Acked-by: Colin Ian King <colin.king at canonical.com>

can you also update:

the man page (the -d, --dump) option needs to detail this change
the help info inside fwts for the -d --dump option (see
fwts_framework_options)
the wiki page https://wiki.ubuntu.com/Kernel/Reference/fwts in the
"Extra Tools" section.

Thanks!





More information about the fwts-devel mailing list