Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 11 Jul 2014 16:45:55 +0000 (UTC)
From:      Bryan Drewery <bdrewery@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r268533 - head/usr.bin/vmstat
Message-ID:  <201407111645.s6BGjt0W077595@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bdrewery
Date: Fri Jul 11 16:45:55 2014
New Revision: 268533
URL: http://svnweb.freebsd.org/changeset/base/268533

Log:
  Fix vmstat -M after r263620 renamed 'cnt' to 'vm_cnt'.
  
  This was showing as:
    vmstat: undefined symbols:
     _cnt
  
  To remain backwards compatible with older dumps, if 'vm_cnt' symbol is not
  found then try again with 'cnt'.
  
  Reported by:	pho
  Sponsored by:	EMC / Isilon Storage Division

Modified:
  head/usr.bin/vmstat/vmstat.c

Modified: head/usr.bin/vmstat/vmstat.c
==============================================================================
--- head/usr.bin/vmstat/vmstat.c	Fri Jul 11 16:26:51 2014	(r268532)
+++ head/usr.bin/vmstat/vmstat.c	Fri Jul 11 16:45:55 2014	(r268533)
@@ -80,7 +80,7 @@ static char da[] = "da";
 
 static struct nlist namelist[] = {
 #define X_SUM		0
-	{ "_cnt" },
+	{ "_vm_cnt" },
 #define X_HZ		1
 	{ "_hz" },
 #define X_STATHZ	2
@@ -259,8 +259,18 @@ main(int argc, char *argv[])
 			errx(1, "kvm_openfiles: %s", errbuf);
 	}
 
+retry_nlist:
 	if (kd != NULL && (c = kvm_nlist(kd, namelist)) != 0) {
 		if (c > 0) {
+			/*
+			 * 'cnt' was renamed to 'vm_cnt'. If 'vm_cnt' is not
+			 * found try looking up older 'cnt' symbol.
+			 * */
+			if (namelist[X_SUM].n_type == 0 &&
+			    strcmp(namelist[X_SUM].n_name, "_vm_cnt") == 0) {
+				namelist[X_SUM].n_name = "_cnt";
+				goto retry_nlist;
+			}
 			warnx("undefined symbols:");
 			for (c = 0;
 			     c < (int)(sizeof(namelist)/sizeof(namelist[0]));



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201407111645.s6BGjt0W077595>