I had the same fun trying to deal with hotplug scripts.
 
The stdout is not connected to where you expect so echoes don't appear.
 
You can do "echo pippo > /tmp/test.txt" and look in the file for the messages 
to debug.
 
I'm sure there's a better way, but that worked for me!

--
Jon Povey, Design Engineer
[EMAIL PROTECTED] | +44(0)1280 825983 

 


________________________________

        From: Gabriele Filosofi [mailto:[EMAIL PROTECTED] 
        Sent: 02 September 2008 10:33
        To: Phil Quiney; Jon Povey; 
[email protected]
        Subject: R: USB flash auto-mounting
        
        

        Phil,

        I'm running git kernel 2.6.25. Following your way I tryed a simpler 
arrangement:

         

        # cat /etc/udev/rules.d/99-usb-automount.rules
        KERNEL=="ub[a-z]1", RUN+="echo pippo"

         

        Then I plug in the usb stick ...

         

        usb 1-1: new high speed USB device using musb_hdrc and address 2

        <6>usb 1-1: configuration #1 chosen from 1 choice

        usb 1-1: configuration #1 chosen from 1 choice

        <6>usb 1-1: New USB device found, idVendor=1370, idProduct=0324

        usb 1-1: New USB device found, idVendor=1370, idProduct=0324

        <6>usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3

        usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3

        <6>usb 1-1: Product: unitedCONTRAST

        usb 1-1: Product: unitedCONTRAST

        <6>usb 1-1: Manufacturer: Swissbit

        usb 1-1: Manufacturer: Swissbit

        <6>usb 1-1: SerialNumber: 000010005690B900008c

        usb 1-1: SerialNumber: 000010005690B900008c

        <6> uba: uba: uba1 uba1

        <6>usbcore: registered new interface driver ub

        usbcore: registered new interface driver ub

         

         

        Nothing more occours, while I expected to see "pippo" label somewhere. 
It seems the /etc/udev/rules.d/ automatism is not working.

         

        Gabriele

         

        Da: Phil Quiney [mailto:[EMAIL PROTECTED] 
        Inviato: martedì 2 settembre 2008 10.30
        A: Jon Povey; Gabriele Filosofi; 
[email protected]
        Oggetto: RE: USB flash auto-mounting

         

        Hi Gabriele,

         

        We have also been round this loop.

         

        You also have the issue that the 'udev' package in the LSP is too old. 
With more recent versions you can trigger an arbitrary program to run on both 
the plug and unplug events. This does not work in the version that ships with 
MV Pro 4.0.1.

         

        For example on a Fedora Core 4 box, I have the following

         

        [EMAIL PROTECTED] udev]# cat rules.d/99-usb-automount.rules
        KERNEL=="sd[a-z]1", RUN+="/usr/local/bin/usb_mount", 
ENV{REMOVE_CMD}="/usr/local/bin/usb_mount"

        Where /usr/local/bin/usb_mount is a script wrapper around mount/umount 
as follows...

         

        #!/bin/bash
        # $Id$
        #
        # Script to automaticlly mount usb devices.  This script is designed to 
work
        # with udev
        #

         

        #commands used in the script
        MOUNT="/bin/mount"
        UMOUNT="/bin/umount -l"
        MKDIR="/bin/mkdir -p"
        RMDIR="/bin/rmdir"

         

        #the root of where all auto mouted devices will be mounted to.
        MOUNT_ROOT=/mnt/auto
        MNT_POINT=$MOUNT_ROOT/${DEVNAME##/dev/}

         

        logger "running $0"
        logger "ACTION=$ACTION ID_BUS=$ID_BUS DEVNAME=$DEVNAME 
ID_FS_TYPE=$ID_FS_TYPE"

         

        # check we are adding a usb device
        if [ "$ID_BUS" != "usb" ]
        then
          logger "ignoring non usb device"
          exit 0
        fi

         

        
        #check the action to process

         

        case "$ACTION" in

         

            add )

         

                logger "mounting new device"

         

                #create the directory we will mount to
                $MKDIR "$MNT_POINT"

         

                #
                #mount the usb device with the following options
                #
                #  ro           - read only
                #  noexec       - Do not allow direct execution of any binaries 
on the mounted file system
                #  nodev        - Do not interpret character or block special 
devices on the file system
                #
                #$MOUNT -t $ID_FS_TYPE $DEVNAME $MNT_POINT -o ro,noexec,nodev
                $MOUNT -t $ID_FS_TYPE $DEVNAME $MNT_POINT -o noexec,nodev

         

                #check if mount suceeded
                if [ $? -eq 0 ]
                then
                # sucess, we mounted ok.
                  logger "mounted $DEVNAME at $MNT_POINT"
                else
                # we failed to mount so remove the mount point
                  logger "failed to mount $DEVNAME at $MNT_POINT"
                  $RMDIR "$MNT_POINT"
                fi
                ;;

         

            remove )

         

                logger "unmounting existing device"

         

                # check if the device is really mounted
                #if [ (grep -q "^$DEVNAME" /proc/mounts || grep -q "^$DEVNAME" 
/etc/mtab) ]
                #then
                # logger "$DEVNAME not mouted"
                #endif

         

                #unmount the device.  We will refer using the mount point not 
the device name
                #becase there is a posibility the device could be removed 
before we
                #do the umount.
                $UMOUNT "$MNT_POINT"

         

                #remove the mount point
                $RMDIR "$MNT_POINT"

         

                logger "unmounted $DEVNAME and removed $MNT_POINT"
                ;;

         

            * )
                logger "ignoring unkown action"
                ;;

         

        esac

        This method works fine on the Fedora Box. Note that the Fedora box is 
in runlevel 3, so no GUI or in fact any screen/keyboard.

         

         

        Regards

         

        Phil Q

         

        Phil Quiney, Senior Software Engineer
        Trinity Convergence
        Cambridge Business Park

        Cowley Road

        Cambridge CB4 0WZ, UK
        T: +44(0)1223-435536
        F: +44(0)1223-435560

        www.trinityconvergence.com <http://www.trinityconvergence.com/> 

         

         

        
________________________________


        From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jon Povey
        Sent: 02 September 2008 08:49
        To: Gabriele Filosofi; [email protected]
        Subject: RE: USB flash auto-mounting

        udev will create the device files but not mount the device (at least 
not in our configuration.. I haven't got much into udev and suspect it of 
taking a lot of processing power on boot so plan to remove it).

         

        We have custom hotplug scripts to mount the device, 
/etc/hotplug/block.agent

        you get a load of environment variables and some command line arguments 
to determine what to do.

         

        hope that helps

        --
        Jon Povey, Design Engineer
        [EMAIL PROTECTED] | +44(0)1280 825983 

         

                 

                
________________________________


                From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of 
Gabriele Filosofi
                Sent: 02 September 2008 08:25
                To: [email protected]
                Subject: USB flash auto-mounting

                Hi,

                I'm wondering if anyone has definitively solved the issue of 
having a USB flash

                drive automatically mount to the file system when it is 
inserted?

                To do this manually is quite simple: 

                 

                mkdir /media/usbflash

                mount -t vfat /dev/uba1 /media/usbflash 

                 

                I wish to make this mount occur automatically every time the 
stick is plugged in.

                I did check .config to see if "CONFIG_HOTPLUG=y": it is.

                In /etc/fstab I put the following line:

                 

                none /proc/bus/usb usbfs defaults 0 0

                 

                but it is not sufficient. 

                 

                Tanks a lot

                 

                Gabriele

                 

                 

                 

                 

                 

                 

                An update on the situation, I?ve gotten the usb flash drive

                automounting, but only if I have it plugged in to the unit 
during

                bootup.  I can?t get it to automount using hotplug or anything 
else.

                The way I have my fstab and udev mounting happening is the 
following:

                 

                udev/rules.d/99-mount.rules :

                BUS=="usb", SYSFS{product}=="JD FIREFLY", KERNEL=="sd?1", 
NAME="lexar",

                SYMLINK="usbdevices/lexar", RUN+="/usr/local/bin/mountlexar.sh"

                 

                fstab:

                /dev/sda1       /media/LEXAR vfat

                rw,nodiratime,sync,nosuid,nodev,noexec,fmask=0033,dmask=0033 0 0

                 

                I think I may have moved around the initialization scripts

                within /etc/rc.d/rcS.d to make the mountall script run after 
all the

                udev stuff but I can't quite remember.  I tried lots of things 
before

                this one finally worked. Good luck, and if i manage to figure 
out the

                hotplug mounting I'll be sure to post it.

                 

                 

                 

                 

                 

                 

                I did check .config to see if "CONFIG_HOTPLUG=y": it is.

                 

                Checking /proc/sys/kernel/hotplug is a good idea: it contains

                "/sbin/udevsend", which is what I would expect to see.

                 

                And also, the udevd daemon is indeed running.

                 

                ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

                  Ing. Gabriele Filosofi

                  [EMAIL PROTECTED] 

                  COSMED srl, R&D Department

                  P.O. Box 3

                  Via dei Piani di Monte Savello, 37

                  00040 - Pavona di Albano, Rome - ITALY

                  Voice: +39-06 931 5492, Fax: +39-06 931 4580

                  http://www.cosmed.it <http://www.cosmed.it/> 

                 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

                 

                 

                 

         

        Racelogic is a limited company registered in England. Registered number 
2743719 . 
        Registered Office Unit 10, Swan Business Centre, Osier Way, Buckingham, 
Bucks, MK18 1TB .

        The information contained in this electronic mail transmission is 
intended by Racelogic Ltd for the use of the named individual or entity to 
which it is directed and may contain information that is confidential or 
privileged. If you have received this electronic mail transmission in error, 
please delete it from your system without copying or forwarding it, and notify 
the sender of the error by reply email so that the sender's address records can 
be corrected. The views expressed by the sender of this communication do not 
necessarily represent those of Racelogic Ltd. Please note that Racelogic 
reserves the right to monitor e-mail communications passing through its network 


 
Racelogic is a limited company registered in England. Registered number 2743719 
. 
Registered Office Unit 10, Swan Business Centre, Osier Way, Buckingham, Bucks, 
MK18 1TB .
The information contained in this electronic mail transmission is intended by 
Racelogic Ltd for the use of the named individual or entity to which it is 
directed and may contain information that is confidential or privileged. If you 
have received this electronic mail transmission in error, please delete it from 
your system without copying or forwarding it, and notify the sender of the 
error by reply email so that the sender's address records can be corrected. The 
views expressed by the sender of this communication do not necessarily 
represent those of Racelogic Ltd. Please note that Racelogic reserves the right 
to monitor e-mail communications passing through its network
_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source

Reply via email to