svn commit: r313258 - head/sbin/nvmecontrol
Warner Losh
imp at FreeBSD.org
Sun Feb 5 00:55:09 UTC 2017
Author: imp
Date: Sun Feb 5 00:55:07 2017
New Revision: 313258
URL: https://svnweb.freebsd.org/changeset/base/313258
Log:
Add the ability to dump log pages directly in binary to stdout.
Update man page to include this flag, and an example of dumping a
vendor-specific page while I'm here.
Modified:
head/sbin/nvmecontrol/logpage.c
head/sbin/nvmecontrol/nvmecontrol.8
Modified: head/sbin/nvmecontrol/logpage.c
==============================================================================
--- head/sbin/nvmecontrol/logpage.c Sun Feb 5 00:45:02 2017 (r313257)
+++ head/sbin/nvmecontrol/logpage.c Sun Feb 5 00:55:07 2017 (r313258)
@@ -74,6 +74,12 @@ kv_lookup(const struct kv_name *kv, size
return bad;
}
+static void
+print_bin(void *data, uint32_t length)
+{
+ write(STDOUT_FILENO, data, length);
+}
+
/*
* 128-bit integer augments to standard values. On i386 this
* doesn't exist, so we use 64-bit values. The 128-bit counters
@@ -872,7 +878,7 @@ logpage(int argc, char *argv[])
{
int fd, nsid;
int log_page = 0, pageflag = false;
- int hexflag = false, ns_specified;
+ int binflag = false, hexflag = false, ns_specified;
char ch, *p;
char cname[64];
uint32_t size;
@@ -882,8 +888,11 @@ logpage(int argc, char *argv[])
struct nvme_controller_data cdata;
print_fn_t print_fn;
- while ((ch = getopt(argc, argv, "p:xv:")) != -1) {
+ while ((ch = getopt(argc, argv, "bp:xv:")) != -1) {
switch (ch) {
+ case 'b':
+ binflag = true;
+ break;
case 'p':
/* TODO: Add human-readable ASCII page IDs */
log_page = strtol(optarg, &p, 0);
@@ -942,7 +951,9 @@ logpage(int argc, char *argv[])
print_fn = print_hex;
size = DEFAULT_SIZE;
- if (!hexflag) {
+ if (binflag)
+ print_fn = print_bin;
+ if (!binflag && !hexflag) {
/*
* See if there is a pretty print function for the specified log
* page. If one isn't found, we just revert to the default
Modified: head/sbin/nvmecontrol/nvmecontrol.8
==============================================================================
--- head/sbin/nvmecontrol/nvmecontrol.8 Sun Feb 5 00:45:02 2017 (r313257)
+++ head/sbin/nvmecontrol/nvmecontrol.8 Sun Feb 5 00:55:07 2017 (r313258)
@@ -33,7 +33,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd September 10, 2016
+.Dd February 4, 2017
.Dt NVMECONTROL 8
.Os
.Sh NAME
@@ -63,6 +63,7 @@
.Aq Fl p Ar page_id
.Op Fl x
.Op Fl v Ar vendor-string
+.Op Fl b
.Aq device id
.Aq namespace id
.Nm
@@ -147,10 +148,21 @@ Display a human-readable summary of the
Log pages defined by the NVMe specification include Error Information Log (ID=1),
SMART/Health Information Log (ID=2), and Firmware Slot Log (ID=3).
.Pp
+.Dl nvmecontrol logpage -p 0xc1 -v wdc nvme0
+.Pp
+Display a human-readable summary of the nvme0's wdc-specific advanced
+SMART data.
+.Pp
.Dl nvmecontrol logpage -p 1 -x nvme0
.Pp
Display a hexadecimal dump of the nvme0 controller's Error Information Log.
.Pp
+.Dl nvmecontrol logpage -p 0xcb -b nvme0 > /tmp/page-cb.bin
+.Pp
+Print the contents of vendor specific page 0xcb as binary data on
+standard out.
+Redirect it to a temporary file.
+.Pp
.Dl nvmecontrol firmware -s 2 -f /tmp/nvme_firmware nvme0
.Pp
Download the firmware image contained in "/tmp/nvme_firmware" to slot 2 of the
More information about the svn-src-all
mailing list