Re: static umass numbering

Christopher Sean Hilton <[email protected]>
Newsgroups gmane.os.freebsd.devel.mobile
Message-ID <[email protected]>
On Tue, 2005-01-18 at 11:36 +0100, Robert Blacquiere wrote:
> Hi folks,
> 
> I have got a couple of usb mass storage devices which work nicely with FreeBSD.
> But they are numbered chronological on insertion. I would like some sort of
> static numbering scheme for easing up for example automounting. 
> Now i use a hand script which take de base da[0-9]+ numbering as var but hate 
> this way of working. 

I'm not sure what you are trying to do but I handled this in 5.3 by
ensuring that the slice and partition layout on all such devices was
uniform. Then I installed a uniformly named script on each drive. The
script can be tailored to provide whatever function the drive supports. 

I use the following layout:

    Slice 1: MSDOS
    Slice 2: FreeBSD
      Partition e: General purpose for automounting
      Partitions a,d,f-h: special purpose

In /etc/amd.map and /etc/fstab I have entries to mount the MSDOS and
FreeBSD partitions from each possible drive:

     /dev/da0s1  --> /amd/msdos0
     /dev/da0s2e --> /amd/da0

     /dev/da1s1  --> /amd/msdos1
     /dev/da1s1e --> /amd/da1

Finally I arrange for devd to run a script from the drive when a new
da[0-9]+ device is attached to the kernel. The devd knows which drive
was attached (da[0-9]+) and can pass that into the script:

     #! /bin/sh

     ...

     device=$1; shift

     ## Use this test to automount the device.

     if test -d /amd/${device}/.; then

         ## Now see if this device has an autorun.sh script for use
         ## on attach.

         if test -f /amd/${device}/autorun.sh; then
             (cd /amd/${device} && sh autorun.sh ${device})
         fi
     fi


Up to here it's basic shell scripting. The problem with all this is that
it all happens as root which I didn't want. So I wrote a daemon and
client which allows the root owned devd process to trigger a user owned
process when a message got passed on a unix domain socket.

-- chris

_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-mobile
To unsubscribe, send any mail to "[email protected]"
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.