diff options
author | Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org> | 2022-04-06 19:47:46 +0200 |
---|---|---|
committer | Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org> | 2022-09-15 18:37:16 +0200 |
commit | a713ecffc834d396a2f97329cc26b4d8b7ffe915 (patch) | |
tree | f5696406182ac3b23c485741780996ae441be93c /usr/src/cmd | |
parent | 8bcd8eea9270aef5b19ce4303b2a7f4f0bc6bbba (diff) | |
download | illumos-gate-a713ecffc834d396a2f97329cc26b4d8b7ffe915.tar.gz |
14954 nvmeadm list should use nicenum()
Reviewed by: Guy Morrogh <gmorrogh@tintri.com>
Reviewed by: Yuri Pankov <ypankov@tintri.com>
Reviewed by: Robert Mustacchi <rm+illumos@fingolfin.org>
Reviewed by: Toomas Soome <tsoome@me.com>
Approved by: Dan McDonald <danmcd@mnx.io>
Diffstat (limited to 'usr/src/cmd')
-rw-r--r-- | usr/src/cmd/nvmeadm/Makefile | 4 | ||||
-rw-r--r-- | usr/src/cmd/nvmeadm/nvmeadm_print.c | 18 |
2 files changed, 14 insertions, 8 deletions
diff --git a/usr/src/cmd/nvmeadm/Makefile b/usr/src/cmd/nvmeadm/Makefile index bc554ec2b8..3ffc68f076 100644 --- a/usr/src/cmd/nvmeadm/Makefile +++ b/usr/src/cmd/nvmeadm/Makefile @@ -10,9 +10,9 @@ # # -# Copyright 2015 Nexenta Systems, Inc. # Copyright (c) 2018, Joyent, Inc. # Copyright 2021 Oxide Computer Company +# Copyright 2022 Tintri by DDN, Inc. All rights reserved. # @@ -27,7 +27,7 @@ include ../Makefile.ctf .KEEP_STATE: CFLAGS += $(CCVERBOSE) -I$(SRC)/uts/common/io/nvme -LDLIBS += -ldevinfo -lofmt +LDLIBS += -ldevinfo -lofmt -lcmdutils CSTD= $(CSTD_GNU99) # diff --git a/usr/src/cmd/nvmeadm/nvmeadm_print.c b/usr/src/cmd/nvmeadm/nvmeadm_print.c index 1acd66860b..d170b48210 100644 --- a/usr/src/cmd/nvmeadm/nvmeadm_print.c +++ b/usr/src/cmd/nvmeadm/nvmeadm_print.c @@ -29,6 +29,7 @@ #include <stdarg.h> #include <err.h> #include <assert.h> +#include <libcmdutils.h> #include "nvmeadm.h" @@ -585,14 +586,19 @@ void nvme_print_nsid_summary(nvme_identify_nsid_t *idns) { int bsize = 1 << idns->id_lbaf[idns->id_flbas.lba_format].lbaf_lbads; + char numbuf[40]; - (void) printf("Size = %"PRId64" MB, " - "Capacity = %"PRId64" MB, " - "Used = %"PRId64" MB\n", - idns->id_nsize * bsize / 1024 / 1024, - idns->id_ncap * bsize / 1024 / 1024, - idns->id_nuse * bsize / 1024 / 1024); + nicenum_scale(idns->id_nsize, bsize, numbuf, sizeof (numbuf), + NN_UNIT_SPACE); + (void) printf("Size = %sB, ", numbuf); + nicenum_scale(idns->id_ncap, bsize, numbuf, sizeof (numbuf), + NN_UNIT_SPACE); + (void) printf("Capacity = %sB, ", numbuf); + + nicenum_scale(idns->id_nuse, bsize, numbuf, sizeof (numbuf), + NN_UNIT_SPACE); + (void) printf("Used = %sB\n", numbuf); } /* |