svn commit: r328721 - stable/11/sbin/nvmecontrol

Alexander Motin mav at FreeBSD.org
Thu Feb 1 19:40:52 UTC 2018


Author: mav
Date: Thu Feb  1 19:40:51 2018
New Revision: 328721
URL: https://svnweb.freebsd.org/changeset/base/328721

Log:
  MFC r313258 (by imp):
  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:
  stable/11/sbin/nvmecontrol/logpage.c
  stable/11/sbin/nvmecontrol/nvmecontrol.8
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sbin/nvmecontrol/logpage.c
==============================================================================
--- stable/11/sbin/nvmecontrol/logpage.c	Thu Feb  1 19:39:33 2018	(r328720)
+++ stable/11/sbin/nvmecontrol/logpage.c	Thu Feb  1 19:40:51 2018	(r328721)
@@ -74,6 +74,12 @@ kv_lookup(const struct kv_name *kv, size_t kv_count, u
 	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: stable/11/sbin/nvmecontrol/nvmecontrol.8
==============================================================================
--- stable/11/sbin/nvmecontrol/nvmecontrol.8	Thu Feb  1 19:39:33 2018	(r328720)
+++ stable/11/sbin/nvmecontrol/nvmecontrol.8	Thu Feb  1 19:40:51 2018	(r328721)
@@ -33,7 +33,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd March 26, 2013
+.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,9 +148,20 @@ Display a human-readable summary of the nvme0 controll
 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


More information about the svn-src-all mailing list