svn commit: r252663 - stable/9/sbin/nvmecontrol

Jim Harris jimharris at FreeBSD.org
Wed Jul 3 23:54:37 UTC 2013


Author: jimharris
Date: Wed Jul  3 23:54:36 2013
New Revision: 252663
URL: http://svnweb.freebsd.org/changeset/base/252663

Log:
  MFC r252270:
  
    Create #defines for NVME_CTRLR_PREFIX and NVME_NS_PREFIX for the "nvme"
    and "ns" strings, rather than hardcoding the string values throughout the
    nvmecontrol code base.
  
  Sponsored by: Intel

Modified:
  stable/9/sbin/nvmecontrol/devlist.c
  stable/9/sbin/nvmecontrol/identify.c
  stable/9/sbin/nvmecontrol/nvmecontrol.h
Directory Properties:
  stable/9/sbin/nvmecontrol/   (props changed)

Modified: stable/9/sbin/nvmecontrol/devlist.c
==============================================================================
--- stable/9/sbin/nvmecontrol/devlist.c	Wed Jul  3 23:53:28 2013	(r252662)
+++ stable/9/sbin/nvmecontrol/devlist.c	Wed Jul  3 23:54:36 2013	(r252663)
@@ -78,7 +78,7 @@ devlist(int argc, char *argv[])
 
 	while (1) {
 		ctrlr++;
-		sprintf(name, "nvme%d", ctrlr);
+		sprintf(name, "%s%d", NVME_CTRLR_PREFIX, ctrlr);
 
 		exit_code = open_dev(name, &fd, 0, 0);
 
@@ -95,7 +95,8 @@ devlist(int argc, char *argv[])
 		printf("%6s: %s\n", name, cdata.mn);
 
 		for (i = 0; i < cdata.nn; i++) {
-			sprintf(name, "nvme%dns%d", ctrlr, i+1);
+			sprintf(name, "%s%d%s%d", NVME_CTRLR_PREFIX, ctrlr,
+			    NVME_NS_PREFIX, i+1);
 			read_namespace_data(fd, i+1, &nsdata);
 			printf("  %10s (%lldGB)\n",
 				name,

Modified: stable/9/sbin/nvmecontrol/identify.c
==============================================================================
--- stable/9/sbin/nvmecontrol/identify.c	Wed Jul  3 23:53:28 2013	(r252662)
+++ stable/9/sbin/nvmecontrol/identify.c	Wed Jul  3 23:54:36 2013	(r252663)
@@ -258,7 +258,7 @@ identify_ns(int argc, char *argv[])
 	 *  of the string.  Don't search past 10 characters into the string,
 	 *  otherwise we know it is malformed.
 	 */
-	nsloc = strnstr(argv[optind], "ns", 10);
+	nsloc = strnstr(argv[optind], NVME_NS_PREFIX, 10);
 	if (nsloc != NULL)
 		nsid = strtol(nsloc + 2, NULL, 10);
 	if (nsloc == NULL || (nsid == 0 && errno != 0)) {
@@ -314,7 +314,7 @@ identify(int argc, char *argv[])
 	 * If device node contains "ns", we consider it a namespace,
 	 *  otherwise, consider it a controller.
 	 */
-	if (strstr(target, "ns") == NULL)
+	if (strstr(target, NVME_NS_PREFIX) == NULL)
 		identify_ctrlr(argc, argv);
 	else
 		identify_ns(argc, argv);

Modified: stable/9/sbin/nvmecontrol/nvmecontrol.h
==============================================================================
--- stable/9/sbin/nvmecontrol/nvmecontrol.h	Wed Jul  3 23:53:28 2013	(r252662)
+++ stable/9/sbin/nvmecontrol/nvmecontrol.h	Wed Jul  3 23:54:36 2013	(r252663)
@@ -31,6 +31,9 @@
 
 #include <dev/nvme/nvme.h>
 
+#define NVME_CTRLR_PREFIX	"nvme"
+#define NVME_NS_PREFIX		"ns"
+
 #define DEVLIST_USAGE							       \
 "       nvmecontrol devlist\n"
 


More information about the svn-src-stable-9 mailing list