git: 4735ef6196bc - main - zonectl: display conventional zones better during RZ

From: Alan Somers <asomers_at_FreeBSD.org>
Date: Sat, 11 Jul 2026 20:31:56 UTC
The branch main has been updated by asomers:

URL: https://cgit.FreeBSD.org/src/commit/?id=4735ef6196bcb2802ad7fc7d1b8054a4756d786b

commit 4735ef6196bcb2802ad7fc7d1b8054a4756d786b
Author:     Alan Somers <asomers@FreeBSD.org>
AuthorDate: 2026-06-09 18:06:13 +0000
Commit:     Alan Somers <asomers@FreeBSD.org>
CommitDate: 2026-07-11 20:31:51 +0000

    zonectl: display conventional zones better during RZ
    
    zonectl's Report Zones subcommand displays a tabular list of zones.  A
    conventional zone's WP column is displayed as 0xffffffffffffffff , the
    literal value that the HDD reports.  But that's too wide for the column,
    causing the text to be misaligned.  It's also not really meaningful,
    because the Write Pointer isn't really defined for a Conventional zone.
    Change it to "-1" to fix the text misalignment.
    
    MFC after:      2 weeks
    Sponsored by:   ConnectWise
    Reviewed by:    fuz
    Differential Revision: https://reviews.freebsd.org/D57512
---
 usr.sbin/zonectl/zonectl.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/usr.sbin/zonectl/zonectl.c b/usr.sbin/zonectl/zonectl.c
index 53e5e6599597..9dc6ddfd1aae 100644
--- a/usr.sbin/zonectl/zonectl.c
+++ b/usr.sbin/zonectl/zonectl.c
@@ -288,11 +288,22 @@ zonectl_print_rz(struct disk_zone_report *report, zone_output_flags out_flags,
 	for (i = 0; i < report->entries_filled; i++) {
 		entry = &report->entries[i];
 
-		printf("%#*jx, %*ju, %#*jx, ", field_widths[ZONE_FW_START],
+		printf("%#*jx, %*ju, ", field_widths[ZONE_FW_START],
 		    (uintmax_t)entry->zone_start_lba,
 		    field_widths[ZONE_FW_LEN],
-		    (uintmax_t)entry->zone_length, field_widths[ZONE_FW_WP],
-		    (uintmax_t)entry->write_pointer_lba);
+		    (uintmax_t)entry->zone_length);
+		if (entry->write_pointer_lba == 0xffffffffffffffff) {
+			/*
+			 * This value is reported by HDDs for conventional
+			 * zones.  It really means "N/A".  Reported it as -1,
+			 * even though it's technically unsigned, to save
+			 * space.
+			 */
+			printf("%*d, ", field_widths[ZONE_FW_WP], -1);
+		} else {
+			printf("%#*jx, ", field_widths[ZONE_FW_WP],
+			    (uintmax_t)entry->write_pointer_lba);
+		}
 
 		switch (entry->zone_type) {
 		case DISK_ZONE_TYPE_CONVENTIONAL: