2009-07-30 12:57:45     How to determine whether the usb device is detected as sda,sda ,sdb....

Document created by Aaronwu Employee on Aug 16, 2013
Version 1Show Document
  • View in full screen mode

2009-07-30 12:57:45     How to determine whether the usb device is detected as sda,sda ,sdb....

sugumar natarajan (INDIA)

Message: 78222   

     

 

Dear Mike,

 

                  Thanks for your inputs on sending signals from kernel to userspace .We have used the pthread_sigmask and were able to sucessfully process the signal.But we have still some issues.During testing we found that some usb device are detected as sda and others  as sda1,sdb,etc..How can we know whether the usb device is detected as sda or sdb ? so that the file system can be mounted for the particular device. for eg  we have the following hot plug script.(please see below highlighed one)

 

here only the device detected as sda is  mounted.can we  know by any way  whether the device is detected as sda,sdb.....

 

We tried the following also,(mentioned in the other thread and also according to our understanding)

 

mount -vfat  $DEVPATH    /mnt

 

This also failed. i checked the value of     $DEVPATH  and these are the values.

 

1.512 m b transend  /block/sda -(hotplug called only one time).

 

2.8mb transend  (hotplug called 2 times)

 

/block/sda/

 

/block/sda/sda1/

 

 

 

hotplug script:

 

#!/bin/sh

output=/dev/ttyBF0

/bin/mdev > $output

echo $DEVPATH | grep sda

if [ $? -ne 0 ]

then

exit 0

fi

echo "Hotplug Script" > $output

echo $ACTION > $output

if [ "${ACTION}" = "add" ] ;then

echo "USB Inserted" > $output

echo $DEVPATH >>devpath

mount -t vfat /dev/sda /mnt

#mount -t vfat /dev/sda /mnt/usb

killall -USR2 ADMTV315

 

So please let us know how to determine if the device is detected as sda,sda1,sdb....

 

Kindly give your inputs.

 

thanks and regards,

 

N.sugumar

QuoteReplyEditDelete

 

 

2009-07-30 14:53:46     Re: How to determine whether the usb device is detected as sda,sda ,sdb....

Chris Brissette (UNITED STATES)

Message: 78224   

 

The best thing that I did when I was playing with the hotplug scripts was to run

 

/bin/env > $output

 

In the script,then you have all of the enviromental variables and something more substantal to work from.

QuoteReplyEditDelete

 

 

2009-07-31 08:29:43     Re: How to determine whether the usb device is detected as sda,sda ,sdb....

Wolfgang Muees (GERMANY)

Message: 78254   

 

In fact, this is very simple.

 

In your mdev.conf, you need an entry to your hotplug script:

 

# SD cards

mmcblk[0-9] 0:0 0664 */opt/auerswald/scripts/hotplug-sd

 

In your hotplug script,

 

#!/bin/sh

 

SD_MPOINT=/data/mnt/sdcard

 

case "$ACTION" in

        add|"")

                mkdir -p $SD_MPOINT

                mount -t auto $MDEV $SD_MPOINT

                ;;

        remove)

                umount $SD_MPOINT

                rmdir $SD_MPOINT

                ;;

esac

 

So the device name is given in $MDEV, and you don't have to make any special provisions for sda or sda1.

 

regards

 

Wolfgang

Attachments

    Outcomes