diff options
| author | Karel Zak <kzak@redhat.com> | 2023-10-25 12:25:37 +0200 |
|---|---|---|
| committer | Karel Zak <kzak@redhat.com> | 2023-11-20 22:25:47 +0100 |
| commit | 7de6a8a91448c9bffdd3370a9884d6c4771de4f3 (patch) | |
| tree | 9371c43ca360909b7ba0f569eae79fd10cda7411 /misc-utils/lsblk.c | |
| parent | 56aad5a88467f3388e5559e717de5b64160478d7 (diff) | |
| download | util-linux-7de6a8a91448c9bffdd3370a9884d6c4771de4f3.tar.gz | |
lsblk: ignore duplicate lines for counters
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'misc-utils/lsblk.c')
| -rw-r--r-- | misc-utils/lsblk.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c index 164e38291c..1810df7714 100644 --- a/misc-utils/lsblk.c +++ b/misc-utils/lsblk.c @@ -1303,7 +1303,7 @@ static void device_to_scols( struct libscols_line *ln; struct lsblk_iter itr; struct lsblk_device *child = NULL; - int link_group = 0; + int link_group = 0, nocount = 0; DBG(DEV, ul_debugobj(dev, "add '%s' to scols", dev->name)); @@ -1379,6 +1379,10 @@ static void device_to_scols( scols_line_link_group(ln, gr, 0); } + /* The same device could be printed more than once, don't use it in counter */ + if (dev->scols_line) + nocount = 1; + dev->scols_line = ln; if (dev->npartitions == 0) @@ -1403,8 +1407,10 @@ static void device_to_scols( } /* apply counters */ - for (i = 0; ln && i < lsblk->ncts; i++) - scols_line_apply_filter(ln, lsblk->ct_filters[i], NULL); + if (!nocount) { + for (i = 0; ln && i < lsblk->ncts; i++) + scols_line_apply_filter(ln, lsblk->ct_filters[i], NULL); + } /* Let's be careful with number of open files */ ul_path_close_dirfd(dev->sysfs); |
