osandov-linux icon indicating copy to clipboard operation
osandov-linux copied to clipboard

Improve suggested "column" usage in btrfs_map_physical

Open leuler opened this issue 2 years ago • 2 comments

The script’s help text suggests to use column -ts …: https://github.com/osandov/osandov-linux/blob/e99136cce98f8c01cd13a55acad1c8a0951e1d44/scripts/btrfs_map_physical.c#L31 This leads to wrong alignment of the values for „DEVID“ and „PHYSICAL OFFSET“ for all but the first device the extent is mirrored on. For example:

FILE OFFSET  FILE SIZE    EXTENT OFFSET  EXTENT TYPE                    LOGICAL SIZE  LOGICAL OFFSET  PHYSICAL SIZE  DEVID  PHYSICAL OFFSET
0            16384        0              regular,compression=lzo,raid1  20480         384156442624    12288          5      5031206912
3            8285986816

Please change the suggestion to column -tns …, which results in correct alignment:

FILE OFFSET  FILE SIZE  EXTENT OFFSET  EXTENT TYPE                    LOGICAL SIZE  LOGICAL OFFSET  PHYSICAL SIZE  DEVID  PHYSICAL OFFSET
0            16384      0              regular,compression=lzo,raid1  20480         384156442624    12288          5      5031206912
                                                                                                                   3      8285986816

Regards,

Lutz

leuler avatar May 28 '22 12:05 leuler

What version of column are you using? I have

$ column --version          
column from util-linux 2.38.1

That version properly aligns the second DEVID and PHYSICAL OFFSET. Furthermore, -n for column from util-linux is documented as -n, --table-name <name> table name for JSON output. See https://man7.org/linux/man-pages/man1/column.1.html.

osandov avatar Aug 10 '22 17:08 osandov

OK, I have a completely different version, not even from util-linux (although the util-linux package is installed, too). My column understands neither --version nor -v, so:

$ dpkg -S `which column`
bsdmainutils: /usr/bin/column
$ apt show bsdmainutils
Package: bsdmainutils
Version: 9.0.12+nmu1
[...]

This is on Debian 9.13.

I looked in the local manpage, and it says about -n:

By default, the column command will merge multiple adjacent delimiters into a single delimiter when using the -t option; this option disables that behavior. This option is a Debian GNU/Linux extension.

I hadn’t noticed this „extension“ wording before, and neither researched my column version, so I assumed column’s behaviour and the -n fix were universally valid. Sorry!

(I also now looked into Debian 10: there the bsdmainutils package is newer, but the behaviour is the same. I don’t have any newer Debians installed, yet.)

So I guess my report is invalid.

leuler avatar Aug 10 '22 18:08 leuler