Page MenuHomeFreeBSD

D32957.1776821785.diff
No OneTemporary

Size
943 B
Referenced Files
None
Subscribers
None

D32957.1776821785.diff

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,14 @@
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 * (uint64_t)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]);
+ break;
+ }
+ size /= 1024;
+ }
}
close(fd);

File Metadata

Mime Type
text/plain
Expires
Wed, Apr 22, 1:36 AM (1 h, 28 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28403015
Default Alt Text
D32957.1776821785.diff (943 B)

Event Timeline