From owner-freebsd-hackers@FreeBSD.ORG Fri Jun 10 01:58:53 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AE46416A41F for ; Fri, 10 Jun 2005 01:58:53 +0000 (GMT) (envelope-from dmp@bitfreak.org) Received: from mail.bitfreak.org (mail.bitfreak.org [65.75.198.146]) by mx1.FreeBSD.org (Postfix) with ESMTP id 70D5443D1D for ; Fri, 10 Jun 2005 01:58:53 +0000 (GMT) (envelope-from dmp@bitfreak.org) Received: from SMILEY (mail.bitfreak.org [65.75.198.146]) by mail.bitfreak.org (Postfix) with ESMTP id 552A319F3B for ; Thu, 9 Jun 2005 19:00:12 -0700 (PDT) From: "Darren Pilgrim" To: Date: Thu, 9 Jun 2005 18:58:44 -0700 Message-ID: <000001c56d5f$efe5c260$0a2a15ac@SMILEY> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.6626 Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 Subject: Determining disk device and kicking GEOM when doing automatic mounting of umass devices X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Jun 2005 01:58:53 -0000 I want to have a devd entry that automatically mounts umass devices when they get attached. The problem is figuring out which device to mount = and then getting the correct devices created. For example, the entry for my thumbdrive: attach 1000 { device-name "umass[0-9]+"; match "vendor" "0x08ec"; match "product" "0x0015"; match "sernum" "0C50935151F0EA20"; action "$scripts/mount_umass.sh $device-name msdosfs /stickdrive"; }; The mount_umass.sh script is as follows: ---BEGIN FILE--- sleep 10 scsidev=3D"`echo ${1} | sed s/umass/umass-sim/g`" diskdev=3D"`camcontrol devlist -v | grep -A 1 ${scsidev} | tail -n 1 | \ awk -F "(" '{ print $2 }' | awk -F "," '{ print $1 }'`" fstype=3D"${2}" mountpoint=3D"${3}" mount -t ${fstype} /dev/${diskdev} ${mountpoint} 2>/dev/null mount -t ${fstype} /dev/${diskdev}s1 ${mountpoint} 2>/dev/null ----END FILE---- First, the script has to sleep because the device doesn't immediately = show up in the CAM device list. After waiting long enough to be safe, the = script takes the device name passed by devd and uses it to parse the device = name from the output of `camcontrol devlist`. GEOM doesn't automatically = read the partition table and create the slice device, so the script forces it = to do so by trying to mount the base device before mounting the actual partition. These tricks are ridiculous, IMO. There has to be a more intelligent = means of going about this. How do I get the scsi disk device name created for = a umass device as soon as it's created? How do I inform GEOM that it = needs to add a new MBR to it's configuration and create the appropriate = /dev/da?s* devices?