From b9c40202d8b96dcfc62cb9caccbbd8f55747377a Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Sat, 17 Feb 2018 06:57:25 +0000 Subject: [PATCH] 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 --- sbin/devmatch/devmatch.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sbin/devmatch/devmatch.c b/sbin/devmatch/devmatch.c index ea284c6296e..3d83d610519 100644 --- a/sbin/devmatch/devmatch.c +++ b/sbin/devmatch/devmatch.c @@ -265,6 +265,7 @@ search_hints(const char *bus, const char *dev, const char *pnpinfo) 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 char *pnpinfo) break; } break; + /* String fields */ case 'D': case 'Z': getstr(&ptr, val1); @@ -313,6 +315,22 @@ search_hints(const char *bus, const char *dev, const char *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: fprintf(stderr, "Unknown field type %c\n:", *cp); break;