Skip to content

Commit

Permalink
Make lsdev -v output line up in neat columns by using a fixed width for
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ian authored and ian committed Feb 17, 2019
1 parent 1eaf4e2 commit 021331d
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions stand/common/disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 021331d

Please sign in to comment.