[PATCH v1] Changing print_dev_t to print raw device number if -Xraw

Dmitry V. Levin ldv at altlinux.org
Sat Dec 1 22:34:42 UTC 2018


On Sat, Dec 01, 2018 at 12:10:47PM -0800, shankarapailoor wrote:
> Hi,
> 
> Attached is a patch to change print_dev_t to print the raw device
> number if -Xraw is passed. Making this an attachment since gmail
> converts tabs to spaces.
> 
> Regards,
> Shankara

> From 5ee7545cbf615b4f1a57ad54b588db0cb5448919 Mon Sep 17 00:00:00 2001
> From: Shankara Pailoor <shankarapailoor at gmail.com>
> Date: Sat, 1 Dec 2018 12:08:07 -0800
> Subject: [PATCH v1] Changing print_dev_t to print raw device number if -Xraw
>  is passed.
> 
> ---
>  print_dev_t.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/print_dev_t.c b/print_dev_t.c
> index 9b62f842..453b2381 100644
> --- a/print_dev_t.c
> +++ b/print_dev_t.c
> @@ -33,5 +33,17 @@
>  void
>  print_dev_t(const unsigned long long dev)
>  {
> +	if (xlat_verbose(xlat_verbosity) != XLAT_STYLE_ABBREV)
> +		tprintf("%llu", dev);
> +
> +	if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_RAW)
> +		return;
> +
> +	if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_VERBOSE)
> +		tprints(" /* ");
> +
>  	tprintf("makedev(%u, %u)", major(dev), minor(dev));
> +
> +	if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_VERBOSE)
> +		tprints("*/");
>  }

This looks good, but have you considered printing the raw value in hex?
Looking at this parser, I think it would be better if major and minor numbers
were printed in hex, too.  For example, stat(1) prints them in hex.

Also, please add a test for this change.


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20181202/4b3d1f16/attachment.bin>


More information about the Strace-devel mailing list