From owner-svn-src-all@freebsd.org Sat Feb 17 06:57:31 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 89663F1438B; Sat, 17 Feb 2018 06:57:31 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2F3C16AA15; Sat, 17 Feb 2018 06:57:26 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2BD0C1943F; Sat, 17 Feb 2018 06:57:26 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w1H6vQ4S027653; Sat, 17 Feb 2018 06:57:26 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1H6vQk0027652; Sat, 17 Feb 2018 06:57:26 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201802170657.w1H6vQk0027652@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Sat, 17 Feb 2018 06:57:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r329442 - head/sbin/devmatch X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/sbin/devmatch X-SVN-Commit-Revision: 329442 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Feb 2018 06:57:31 -0000 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: