]> git.ipfire.org Git - thirdparty/util-linux.git/commit
lsblk: add scols counters support
authorKarel Zak <kzak@redhat.com>
Tue, 26 Sep 2023 10:52:32 +0000 (12:52 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 20 Nov 2023 21:25:46 +0000 (22:25 +0100)
commit0398951e877cede5543dcbc23704a2cf9a93beaa
tree271b103221303fa82e1ed20cf8ba2541a985208f
parent3aeacd6a47df358da0b945496e5e29c5063aca4d
lsblk: add scols counters support

* add --ct-filter <expr> to restrict the next next counters

* add --ct <name>[:<param>:func] to define counter. The counter
  assigned to the previously specified filter, if no filter specified
  then it's applied to all output lines.

Examples:

  $ lsblk --ct "number of block devices"
  ...
  Summary:
              21 number of block devices

The filter uses default count() function and is applied to
all lines.

  $ lsblk --ct-filter 'TRAN=="nvme"' --ct "number of NVMEs"
  ...
  Summary:
               4 number of NVMEs

The filter is restricted by filter.

  $ lsblk --bytes
          --ct-filter 'TRAN=="sata" && TYPE=="disk"'
          --ct "size of all SATAs disks":SIZE:sum
  ...
  Summary:
    320083771392 size of all SATAs disks

The counter uses sum() built-in function for specified column (SIZE)
and is restricted by filter.

Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/lsblk.c
misc-utils/lsblk.h