Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 17 Feb 2019 23:46:12 +0000 (UTC)
From:      Ian Lepore <ian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r344240 - head/stand/common
Message-ID:  <201902172346.x1HNkCSl067351@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ian
Date: Sun Feb 17 23:46:11 2019
New Revision: 344240
URL: https://svnweb.freebsd.org/changeset/base/344240

Log:
  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

Modified:
  head/stand/common/disk.c

Modified: head/stand/common/disk.c
==============================================================================
--- head/stand/common/disk.c	Sun Feb 17 23:38:17 2019	(r344239)
+++ head/stand/common/disk.c	Sun Feb 17 23:46:11 2019	(r344240)
@@ -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 struc
 	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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201902172346.x1HNkCSl067351>