From 021331dbf4e4596a4d9d51c0d5bba54932b976f8 Mon Sep 17 00:00:00 2001 From: ian Date: Sun, 17 Feb 2019 23:46:11 +0000 Subject: [PATCH] Make lsdev -v output line up in neat columns by using a fixed width for the size field and a tab between the partition type and the size. Changes this disk devices: disk0 (MMC) disk0s1: DOS/Windows 49MB disk0s2: FreeBSD 14GB disk0s2a: FreeBSD UFS 14GB disk0s2b: Unknown 2048KB disk0s2d: FreeBSD UFS 2040KB to this disk devices: disk0 (MMC) disk0s1: DOS/Windows 49MB disk0s2: FreeBSD 14GB disk0s2a: FreeBSD UFS 14GB disk0s2b: Unknown 2048KB disk0s2d: FreeBSD UFS 2040KB --- stand/common/disk.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/stand/common/disk.c b/stand/common/disk.c index 0f7a3543da2..c008179cb02 100644 --- a/stand/common/disk.c +++ b/stand/common/disk.c @@ -75,7 +75,7 @@ display_size(uint64_t size, u_int sectorsize) size /= 1024; unit = 'M'; } - sprintf(buf, "%ld%cB", (long)size, unit); + sprintf(buf, "%4ld%cB", (long)size, unit); return (buf); } @@ -119,12 +119,9 @@ ptable_print(void *arg, const char *pname, const struct ptable_entry *part) od = (struct open_disk *)pa->dev->dd.d_opendata; sectsize = od->sectorsize; partsize = part->end - part->start + 1; - sprintf(line, " %s%s: %s", pa->prefix, pname, - parttype2str(part->type)); - if (pa->verbose) - sprintf(line, "%-*s%s", PWIDTH, line, - display_size(partsize, sectsize)); - strcat(line, "\n"); + sprintf(line, " %s%s: %s\t%s\n", pa->prefix, pname, + parttype2str(part->type), + pa->verbose ? display_size(partsize, sectsize) : ""); if (pager_output(line)) return 1; res = 0; -- 2.45.0