Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F153727212
D32957.id99042.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D32957.id99042.diff
View Options
Index: sbin/nvmecontrol/devlist.c
===================================================================
--- sbin/nvmecontrol/devlist.c
+++ sbin/nvmecontrol/devlist.c
@@ -34,6 +34,8 @@
#include <err.h>
#include <errno.h>
#include <fcntl.h>
+#include <stdbool.h>
+#include <libutil.h>
#include <paths.h>
#include <stddef.h>
#include <stdio.h>
@@ -51,10 +53,27 @@
static cmd_fn_t devlist;
+static struct options {
+ bool human;
+} opt = {
+ .human = false,
+};
+
+static const struct opts devlist_opts[] = {
+#define OPT(l, s, t, opt, addr, desc) { l, s, t, &opt.addr, desc }
+ OPT("human", 'h', arg_none, opt, human,
+ "Show human readable disk size"),
+ { NULL, 0, arg_none, NULL, NULL }
+};
+#undef OPT
+
static struct cmd devlist_cmd = {
.name = "devlist",
.fn = devlist,
- .descr = "List NVMe controllers and namespaces"
+ .descr = "List NVMe controllers and namespaces",
+ .ctx_size = sizeof(opt),
+ .opts = devlist_opts,
+ .args = NULL,
};
CMD_COMMAND(devlist_cmd);
@@ -81,7 +100,9 @@
struct nvme_namespace_data nsdata;
char name[64];
uint8_t mn[64];
+ uint8_t buf[7];
uint32_t i;
+ uint64_t size;
int ctrlr, fd, found, ret;
if (arg_parse(argc, argv, f))
@@ -115,11 +136,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 * (uint64_t)ns_get_sector_size(&nsdata);
+ if (opt.human) {
+ humanize_number(buf, sizeof(buf), size, "B",
+ HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL);
+ printf(" %10s (%s)\n", name, buf);
+
+ } else {
+ printf(" %10s (%luMB)\n", name, size / 1024 / 1024);
+ }
}
close(fd);
Index: sbin/nvmecontrol/nvmecontrol.8
===================================================================
--- sbin/nvmecontrol/nvmecontrol.8
+++ sbin/nvmecontrol/nvmecontrol.8
@@ -44,6 +44,7 @@
.Sh SYNOPSIS
.Nm
.Ic devlist
+.Op Fl h
.Nm
.Ic identify
.Op Fl v
@@ -209,6 +210,13 @@
.Sh DESCRIPTION
NVM Express (NVMe) is a storage protocol standard, for SSDs and other
high-speed storage devices over PCI Express.
+.Ss devlist
+List all NVMe controllers and namespaces along with their device nodes.
+With the
+.Fl h
+argument, use unit suffixes: Byte, Kibibyte, Mebibyte, Gibibyte, Tebibyte
+and Pebibyte (based on powers of 1024) when showing the disk space.
+By default, uses Mebibyte.
.Ss identify
The identify commands reports information from the drive's
.Dv IDENTIFY_CONTROLLER
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Apr 24, 6:29 AM (21 h, 18 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
32063785
Default Alt Text
D32957.id99042.diff (2 KB)
Attached To
Mode
D32957: nvmecontrol: improve namespace size unit of devlist command output
Attached
Detach File
Event Timeline
Log In to Comment