summaryrefslogtreecommitdiffstats
path: root/sys/boot
diff options
context:
space:
mode:
authornyan <nyan@FreeBSD.org>2008-02-29 04:56:51 +0000
committernyan <nyan@FreeBSD.org>2008-02-29 04:56:51 +0000
commitb1d88bacd7be6e1a96583a5f2ad5a982cc68070e (patch)
tree8d06602af7ad70653f8661656e2a231b56cbb788 /sys/boot
parentc125e780ea3de90a944321e7f266190de9101e4a (diff)
downloadFreeBSD-src-b1d88bacd7be6e1a96583a5f2ad5a982cc68070e.zip
FreeBSD-src-b1d88bacd7be6e1a96583a5f2ad5a982cc68070e.tar.gz
MFi386: revision 1.55.
Tweak the verbose disk printing a bit.
Diffstat (limited to 'sys/boot')
-rw-r--r--sys/boot/pc98/libpc98/biosdisk.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/sys/boot/pc98/libpc98/biosdisk.c b/sys/boot/pc98/libpc98/biosdisk.c
index 6092a37..dc5f82d 100644
--- a/sys/boot/pc98/libpc98/biosdisk.c
+++ b/sys/boot/pc98/libpc98/biosdisk.c
@@ -287,6 +287,29 @@ bd_print(int verbose)
}
}
+/* Given a size in 512 byte sectors, convert it to a human-readable number. */
+static char *
+display_size(uint64_t size)
+{
+ static char buf[80];
+ char unit;
+
+ size /= 2;
+ unit = 'K';
+ if (size >= 10485760000LL) {
+ size /= 1073741824;
+ unit = 'T';
+ } else if (size >= 10240000) {
+ size /= 1048576;
+ unit = 'G';
+ } else if (size >= 10000) {
+ size /= 1024;
+ unit = 'M';
+ }
+ sprintf(buf, "%.6ld%cB", (long)size, unit);
+ return (buf);
+}
+
/*
* Print out each valid partition in the disklabel of a FreeBSD slice.
* For size calculations, we assume a 512 byte sector size.
@@ -326,11 +349,11 @@ bd_printbsdslice(struct open_disk *od, daddr_t offset, char *prefix,
/* Only print out statistics in verbose mode */
if (verbose)
- sprintf(line, " %s%c: %s %.6dMB (%d - %d)\n", prefix, 'a' + i,
- (lp->d_partitions[i].p_fstype == FS_SWAP) ? "swap" :
+ sprintf(line, " %s%c: %s %s (%d - %d)\n", prefix, 'a' + i,
+ (lp->d_partitions[i].p_fstype == FS_SWAP) ? "swap " :
(lp->d_partitions[i].p_fstype == FS_VINUM) ? "vinum" :
- "FFS",
- lp->d_partitions[i].p_size / 2048,
+ "FFS ",
+ display_size(lp->d_partitions[i].p_size),
lp->d_partitions[i].p_offset,
lp->d_partitions[i].p_offset + lp->d_partitions[i].p_size);
else
OpenPOWER on IntegriCloud