From owner-svn-src-all@FreeBSD.ORG Mon Mar 4 05:46:56 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 38147DE6; Mon, 4 Mar 2013 05:46:56 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 1BDE7D58; Mon, 4 Mar 2013 05:46:56 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r245ktub008794; Mon, 4 Mar 2013 05:46:56 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r245ktxQ008788; Mon, 4 Mar 2013 05:46:55 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201303040546.r245ktxQ008788@svn.freebsd.org> From: Hiroki Sato Date: Mon, 4 Mar 2013 05:46:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r247768 - in stable/8: etc sbin/devd X-SVN-Group: stable-8 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.14 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: Mon, 04 Mar 2013 05:46:56 -0000 Author: hrs Date: Mon Mar 4 05:46:54 2013 New Revision: 247768 URL: http://svnweb.freebsd.org/changeset/base/247768 Log: MFC r226775: - Add support for a "!" character in regex matching in devd(8). It inverts the logic (true/false) of the matching. - Add "!usbus[0-9]+" to IFNET ATTACH notification handler in the default devd.conf to prevent rc.d/netif from running when usbus[0-9]+ is attached. Modified: stable/8/etc/devd.conf stable/8/sbin/devd/devd.cc stable/8/sbin/devd/devd.conf.5 stable/8/sbin/devd/devd.hh Directory Properties: stable/8/etc/ (props changed) stable/8/sbin/devd/ (props changed) Modified: stable/8/etc/devd.conf ============================================================================== --- stable/8/etc/devd.conf Mon Mar 4 05:46:35 2013 (r247767) +++ stable/8/etc/devd.conf Mon Mar 4 05:46:54 2013 (r247768) @@ -38,6 +38,7 @@ options { # notify 0 { match "system" "IFNET"; + match "subsystem" "!usbus[0-9]+"; match "type" "ATTACH"; action "/etc/pccard_ether $subsystem start"; }; Modified: stable/8/sbin/devd/devd.cc ============================================================================== --- stable/8/sbin/devd/devd.cc Mon Mar 4 05:46:35 2013 (r247767) +++ stable/8/sbin/devd/devd.cc Mon Mar 4 05:46:54 2013 (r247768) @@ -167,7 +167,14 @@ match::match(config &c, const char *var, { string pattern = re; _re = "^"; - _re.append(c.expand_string(string(re))); + if (!c.expand_string(string(re)).empty() && + c.expand_string(string(re)).at(0) == '!') { + _re.append(c.expand_string(string(re)).substr(1)); + _inv = 1; + } else { + _re.append(c.expand_string(string(re))); + _inv = 0; + } _re.append("$"); regcomp(&_regex, _re.c_str(), REG_EXTENDED | REG_NOSUB | REG_ICASE); } @@ -184,10 +191,13 @@ match::do_match(config &c) bool retval; if (Dflag) - fprintf(stderr, "Testing %s=%s against %s\n", _var.c_str(), - value.c_str(), _re.c_str()); + fprintf(stderr, "Testing %s=%s against %s, invert=%d\n", + _var.c_str(), value.c_str(), _re.c_str(), _inv); retval = (regexec(&_regex, value.c_str(), 0, NULL, 0) == 0); + if (_inv == 1) + retval = (retval == 0) ? 1 : 0; + return retval; } Modified: stable/8/sbin/devd/devd.conf.5 ============================================================================== --- stable/8/sbin/devd/devd.conf.5 Mon Mar 4 05:46:35 2013 (r247767) +++ stable/8/sbin/devd/devd.conf.5 Mon Mar 4 05:46:54 2013 (r247768) @@ -41,7 +41,7 @@ .\" ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS .\" SOFTWARE. .\" -.Dd March 8, 2009 +.Dd March 4, 2013 .Dt DEVD.CONF 5 .Os .Sh NAME @@ -122,6 +122,10 @@ Creates a regular expression and assigns .Ar regexp-name . The variable is available throughout the rest of the configuration file. +If the string begins with +.Ql \&! , +it matches if the regular expression formed by the rest of the string +does not match. All regular expressions have an implicit .Ql ^$ around them. Modified: stable/8/sbin/devd/devd.hh ============================================================================== --- stable/8/sbin/devd/devd.hh Mon Mar 4 05:46:35 2013 (r247767) +++ stable/8/sbin/devd/devd.hh Mon Mar 4 05:46:54 2013 (r247768) @@ -92,6 +92,7 @@ public: private: std::string _var; std::string _re; + bool _inv; regex_t _regex; };