svn commit: r329442 - head/sbin/devmatch

Warner Losh imp at FreeBSD.org
Sat Feb 17 06:57:31 UTC 2018


Author: imp
Date: Sat Feb 17 06:57:25 2018
New Revision: 329442
URL: https://svnweb.freebsd.org/changeset/base/329442

Log:
  Implement 'T' field matching.
  
  Implement 'T' field matching. This is needed to prevent false
  positives. However, it's not general enough. It only handles one field
  and there's a ton of edge cases even with that it likely wouldn't
  handle. To do it more generally and also eliminate a lot of the
  hackiness that's in this program now, we'd need to creating
  directories for lookups ala awk, pearl, python, etc. It appears to be
  sufficient, though, to get my keyboard loaded on boot.
  
  Sponsored by: Netflix

Modified:
  head/sbin/devmatch/devmatch.c

Modified: head/sbin/devmatch/devmatch.c
==============================================================================
--- head/sbin/devmatch/devmatch.c	Sat Feb 17 06:57:21 2018	(r329441)
+++ head/sbin/devmatch/devmatch.c	Sat Feb 17 06:57:25 2018	(r329442)
@@ -265,6 +265,7 @@ search_hints(const char *bus, const char *dev, const c
 				bit = -1;
 				do {
 					switch (*cp) {
+						/* All integer fields */
 					case 'I':
 					case 'J':
 					case 'G':
@@ -300,6 +301,7 @@ search_hints(const char *bus, const char *dev, const c
 							break;
 						}
 						break;
+						/* String fields */
 					case 'D':
 					case 'Z':
 						getstr(&ptr, val1);
@@ -311,6 +313,22 @@ search_hints(const char *bus, const char *dev, const c
 							break;
 						s = pnpval_as_str(cp + 2, pnpinfo);
 						if (strcmp(s, val1) != 0)
+							notme++;
+						break;
+						/* Key override fields, required to be last in the string */
+					case 'T':
+						/*
+						 * This is imperfect and only does one key and will be redone
+						 * to be more general for multiple keys. Currently, nothing
+						 * does that.
+						 */
+						if (dump_flag)				/* No per-row data stored */
+							break;
+						if (cp[strlen(cp) - 1] == ';')		/* Skip required ; at end */
+							cp[strlen(cp) - 1] = '\0';	/* in case it's not there */
+						if ((s = strstr(pnpinfo, cp + 2)) == NULL)
+							notme++;
+						else if (s > pnpinfo && s[-1] != ' ')
 							notme++;
 						break;
 					default:


More information about the svn-src-head mailing list