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
This commit is contained in:
Ian Lepore 2019-02-17 23:46:11 +00:00
parent 71c96def1c
commit 5b777dbfa5
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=344240

View File

@ -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;