From: Andreas Hindborg Date: Wed, 16 Mar 2022 08:39:05 +0000 (+0100) Subject: blkzone: Do not print zone capacity if not supported X-Git-Tag: v2.38-rc4~6 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=efea86773ef57245bf821c51811d89309eb37e9a;p=thirdparty%2Futil-linux.git blkzone: Do not print zone capacity if not supported 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 --- diff --git a/sys-utils/blkzone.c b/sys-utils/blkzone.c index ee70c71f36..04e2660044 100644 --- a/sys-utils/blkzone.c +++ b/sys-utils/blkzone.c @@ -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--;