Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 9 Jun 2005 18:58:44 -0700
From:      "Darren Pilgrim" <dmp@bitfreak.org>
To:        <freebsd-hackers@freebsd.org>
Subject:   Determining disk device and kicking GEOM when doing automatic mounting of umass devices
Message-ID:  <000001c56d5f$efe5c260$0a2a15ac@SMILEY>

next in thread | raw e-mail | index | archive | help
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?





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?000001c56d5f$efe5c260$0a2a15ac>