Index: sbin/nvmecontrol/devlist.c =================================================================== --- sbin/nvmecontrol/devlist.c +++ sbin/nvmecontrol/devlist.c @@ -81,8 +81,10 @@ struct nvme_namespace_data nsdata; char name[64]; uint8_t mn[64]; - uint32_t i; + uint32_t i, j; + uint64_t size; int ctrlr, fd, found, ret; + const char *unit = "YZEPTGMK"; if (arg_parse(argc, argv, f)) return; @@ -115,11 +117,15 @@ continue; sprintf(name, "%s%d%s%d", NVME_CTRLR_PREFIX, ctrlr, NVME_NS_PREFIX, i + 1); - printf(" %10s (%lldMB)\n", - name, - nsdata.nsze * - (long long)ns_get_sector_size(&nsdata) / - 1024 / 1024); + size = nsdata.nsze * (double)ns_get_sector_size(&nsdata); + for (j = strlen(unit); j >= 0; j--) { + if (j == 0 || size < 10240) { + printf(" %10s (%lu%cB)\n", name, size, unit[j]); + goto next; + } + size /= 1024; + } + next:; } close(fd);