diff options
-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); } /* |