From owner-freebsd-questions@FreeBSD.ORG Mon Dec 5 17:25:11 2011 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 205BA1065678 for ; Mon, 5 Dec 2011 17:25:11 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx02.qsc.de (mx02.qsc.de [213.148.130.14]) by mx1.freebsd.org (Postfix) with ESMTP id D8E1B8FC1F for ; Mon, 5 Dec 2011 17:25:10 +0000 (UTC) Received: from r56.edvax.de (port-92-195-89-217.dynamic.qsc.de [92.195.89.217]) by mx02.qsc.de (Postfix) with ESMTP id 35B221DB59; Mon, 5 Dec 2011 18:25:08 +0100 (CET) Received: from r56.edvax.de (localhost [127.0.0.1]) by r56.edvax.de (8.14.5/8.14.5) with SMTP id pB5HP8st002831; Mon, 5 Dec 2011 18:25:08 +0100 (CET) (envelope-from freebsd@edvax.de) Date: Mon, 5 Dec 2011 18:25:08 +0100 From: Polytropon To: Mike Clarke Message-Id: <20111205182508.005fd1fd.freebsd@edvax.de> In-Reply-To: <201112051708.16072.jmc-freebsd2@milibyte.co.uk> References: <201112051708.16072.jmc-freebsd2@milibyte.co.uk> Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: freebsd-questions@freebsd.org Subject: Re: umass to /dev/da* mapping X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Polytropon List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Dec 2011 17:25:11 -0000 On Mon, 5 Dec 2011 17:08:15 +0000, Mike Clarke wrote: > > I have a fairly simple perl script which is run by devd when I plug in a > USB memory stick. The script sets up some permissions and a link to > make life easy for a user to mount the memory stick. > > This normally works fine but there are problems if the memory stick is > already inserted before booting. > > Normally my internal 4 slot memory card reader is detected as umass0 > with devices da[0-3] and when the USB memory stick is inserted it comes > up as umass1 with device da4 and my script works on that assumption. If > the USB stick is present on booting then it appears as da0 on umass0 > and the card reader is da[1-4] on umass1 so the script fails. > > Is there any convenient way for my script to determine which da* devices > correspond to the umass device name? Maybe you could use a matching against match "bus" "0x????"; match "vendor" "0x????"; match "product" "0x????"; match "release" "0x????"; to determine which device you're currently accessing. As the USB IDs stay the same for at least the card reader, it should be easy to conclude. :-) USB devices are usually "enumerated" in the order they appear to the system. -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...