From owner-freebsd-usb@FreeBSD.ORG Tue Feb 24 23:28:35 2015 Return-Path: Delivered-To: freebsd-usb@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A3F19446; Tue, 24 Feb 2015 23:28:35 +0000 (UTC) Received: from pmta2.delivery6.ore.mailhop.org (pmta2.delivery6.ore.mailhop.org [54.200.129.228]) by mx1.freebsd.org (Postfix) with ESMTP id 8244FBC0; Tue, 24 Feb 2015 23:28:34 +0000 (UTC) Received: from smtp7.ore.mailhop.org (172.31.36.112) by pmta2.delivery1.ore.mailhop.org id htk4im20u501; Tue, 24 Feb 2015 22:38:13 +0000 (envelope-from ) Received: from c-73-34-117-227.hsd1.co.comcast.net ([73.34.117.227] helo=ilsoft.org) by smtp7.ore.mailhop.org with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.82) (envelope-from ) id 1YQO7B-0007ed-QY; Tue, 24 Feb 2015 22:38:05 +0000 Received: from revolution.hippie.lan (revolution.hippie.lan [172.22.42.240]) by ilsoft.org (8.14.9/8.14.9) with ESMTP id t1OMc1Ou012147; Tue, 24 Feb 2015 15:38:01 -0700 (MST) (envelope-from ian@freebsd.org) X-Mail-Handler: DuoCircle Outbound SMTP X-Originating-IP: 73.34.117.227 X-Report-Abuse-To: abuse@duocircle.com (see https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information for abuse reporting information) X-MHO-User: U2FsdGVkX1/rc8iYaQq17L9lJNOz3LRT Message-ID: <1424817481.1328.9.camel@freebsd.org> Subject: Re: [Bug 198015] devd(8) overwrites "bus" on ugen event From: Ian Lepore To: bugzilla-noreply@freebsd.org Date: Tue, 24 Feb 2015 15:38:01 -0700 In-Reply-To: References: Content-Type: text/plain; charset="us-ascii" X-Mailer: Evolution 3.12.10 FreeBSD GNOME Team Port Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Cc: freebsd-usb@FreeBSD.org X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Feb 2015 23:28:35 -0000 On Tue, 2015-02-24 at 21:47 +0000, bugzilla-noreply@freebsd.org wrote: > https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=198015 > > Bug ID: 198015 > Summary: devd(8) overwrites "bus" on ugen event > Product: Base System > Version: 10.1-RELEASE > Hardware: Any > OS: Any > Status: New > Severity: Affects Only Me > Priority: --- > Component: usb > Assignee: freebsd-usb@FreeBSD.org > Reporter: johan@stromnet.se > > Problem: > When trying to match a uftdi device arrival, "bus" variable is overwritten. > This means I cannot know which /dev/ugenN.N node to work with (which in my case > is chown to a specific user). > > Example: (FreeBSD 10.1, devd in console mode): > > Sample devd script: > attach 10 { > device-name "uftdi[0-9]+"; > action "chgrp dialer /dev/ugen$bus.$devaddr; chmod 660 > /dev/ugen$bus.$devaddr" > }; > > Processing event '+uftdi0 at bus=0 hubaddr=1 port=3 devaddr=2 interface=0 > vendor=0x1781 product=0x0c30 devclass=0x00 devsubclass=0x00 sernum="XXXXXX" > release=0x0600 mode=host intclass=0xff intsubclass=0xff intprotocol=0xff > ttyname=U0 ttyports=1 on uhub1' > Pushing table > setting device-name=uftdi0 > setting bus=0 > setting hubaddr=1 > setting port=3 > setting devaddr=2 > setting interface=0 > setting vendor=0x1781 > setting product=0x0c30 > setting devclass=0x00 > setting devsubclass=0x00 > setting sernum=A6008W8a > setting release=0x0600 > setting mode=host > setting intclass=0xff > setting intsubclass=0xff > setting intprotocol=0xff > setting ttyname=U0 > setting ttyports=1 > setting bus=uhub1 > Processing attach event > Testing device-name=uftdi0 against ^ed50$, invert=0 > Testing device-name=uftdi0 against ^ubt[0-9]+$, invert=0 > Testing device-name=uftdi0 against ^ukbd0$, invert=0 > Testing vendor=0x1781 against ^0x0854$, invert=0 > Testing vendor=0x1781 against ^0x1645$, invert=0 > Testing device-name=uftdi0 against ^uftdi[0-9]+$, invert=0 > Testing vendor=0x1781 against ^0x0403$, invert=0 > Testing device-name=uftdi0 against ^uftdi[0-9]+$, invert=0 > Testing vendor=0x1781 against ^0x1781$, invert=0 > Testing product=0x0c30 against ^0x0c30$, invert=0 > Executing 'chgrp dialer /dev/ugenuhub1.2; chmod 660 /dev/ugenuhub1.2' > chgrp: /dev/ugenuhub1.2: No such file or directory > chmod: /dev/ugenuhub1.2: No such file or directory > Popping table > > > My suspect: > https://github.com/freebsd/freebsd/blob/master/sbin/devd/devd.cc#L821 > > > > Is there any other way to reliably get the corresponding ugen device? > This is pretty yucky to fix. My first thought was that the pnpinfo should contain usbus= rather than bus=, but I checked, and making that change will break our software at $work (and thus presumably other 3rd party software that directly reads devd.pipe and relies on the current format of usb pnpinfo too). Another possibility would be to add usbus= to pnpinfo and also leave bus= there for compatibility with out-of-tree software. Yet another possibility would be to add a ugen=n.n to pnpinfo. I especially like this idea. -- Ian