In verbose mode print disk sizes in human readable form as well.

OK'ed by:	phk
This commit is contained in:
Pawel Jakub Dawidek 2004-05-24 22:52:32 +00:00
parent 7d3940bb67
commit 991d64ece8
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=129679
2 changed files with 9 additions and 2 deletions

View File

@ -5,6 +5,9 @@ MAN= diskinfo.8
WARNS?= 5 WARNS?= 5
DPADD= ${LIBUTIL}
LDADD= -lutil
.include <bsd.prog.mk> .include <bsd.prog.mk>
test: ${PROG} test: ${PROG}

View File

@ -35,6 +35,7 @@
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <libutil.h>
#include <paths.h> #include <paths.h>
#include <err.h> #include <err.h>
#include <sys/disk.h> #include <sys/disk.h>
@ -110,10 +111,13 @@ main(int argc, char **argv)
printf("\t%u", fwsectors); printf("\t%u", fwsectors);
} }
} else { } else {
humanize_number(buf, 6 - (mediasize < 0 ? 0 : 1),
(int64_t)mediasize, "",
HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL);
printf("%s\n", argv[i]); printf("%s\n", argv[i]);
printf("\t%-12u\t# sectorsize\n", sectorsize); printf("\t%-12u\t# sectorsize\n", sectorsize);
printf("\t%-12jd\t# mediasize in bytes\n", printf("\t%-12jd\t# mediasize in bytes (%s)\n",
(intmax_t)mediasize); (intmax_t)mediasize, buf);
printf("\t%-12jd\t# mediasize in sectors\n", printf("\t%-12jd\t# mediasize in sectors\n",
(intmax_t)mediasize/sectorsize); (intmax_t)mediasize/sectorsize);
if (fwsectors != 0 && fwheads != 0) { if (fwsectors != 0 && fwheads != 0) {