]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
blkzone: Do not print zone capacity if not supported
authorAndreas Hindborg <andreas.hindborg@wdc.com>
Wed, 16 Mar 2022 08:39:05 +0000 (09:39 +0100)
committerAndreas Hindborg <andreas.hindborg@wdc.com>
Wed, 16 Mar 2022 09:32:38 +0000 (10:32 +0100)
If `blkzone` is built against kernel headers that do not define
`BLK_ZONE_REP_CAPACITY`, `blkzone report` will use zone size when printing zone
capacity. This patch changes the behavior of `blockzone report` in this case to
omit the capacity field instead of using the potentially wrong value.

Signed-off-by: Andreas Hindborg <andreas.hindborg@wdc.com>
sys-utils/blkzone.c

index ee70c71f36a41e444e1aa2f3f99712c81694c568..04e2660044fce6f39511a111b381a372b9f57f0c 100644 (file)
@@ -298,7 +298,7 @@ static int blkzone_report(struct blkzone_control *ctl)
 
                        if (only_capacity_sum) {
                                capacity_sum += cap;
-                       } else {
+                       } else if (has_zone_capacity(zi)) {
                                printf(_("  start: 0x%09"PRIx64", len 0x%06"PRIx64
                                        ", cap 0x%06"PRIx64", wptr 0x%06"PRIx64
                                        " reset:%u non-seq:%u, zcond:%2u(%s) [type: %u(%s)]\n"),
@@ -306,6 +306,14 @@ static int blkzone_report(struct blkzone_control *ctl)
                                        entry->reset, entry->non_seq,
                                        cond, condition_str[cond & (ARRAY_SIZE(condition_str) - 1)],
                                        type, type_text[type]);
+                       } else {
+                               printf(_("  start: 0x%09"PRIx64", len 0x%06"PRIx64
+                                       ", wptr 0x%06"PRIx64
+                                       " reset:%u non-seq:%u, zcond:%2u(%s) [type: %u(%s)]\n"),
+                                       start, len, (type == 0x1) ? 0 : wp - start,
+                                       entry->reset, entry->non_seq,
+                                       cond, condition_str[cond & (ARRAY_SIZE(condition_str) - 1)],
+                                       type, type_text[type]);
                        }
 
                        nr_zones--;