Saturday, October 18, 2008

Using udev to connect my phone

I want to use udev to recognise my mobile phone and then have a script run which puts all my Podcasts onto the phone.

When I connect the phone, I get the following from dmesg
usb 5-2: new full speed USB device using uhci_hcd and address 2
usb 5-2: configuration #1 chosen from 1 choice
usb 5-2: New USB device found, idVendor=22b8, idProduct=6410
usb 5-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 5-2: Product: Motorola Phone (RAZRV3xx)
usb 5-2: Manufacturer: Motorola Inc.
usb 5-2: SerialNumber: 615044B60B0909
Initializing USB Mass Storage driver...
scsi4 : SCSI emulation for USB Mass Storage devices
usb-storage: device found at 2
usb-storage: waiting for device to settle before scanning
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.


Which unfortunately does not tell me what /dev/ is being used.

I know the phone was mounted as /mount/disk, so I use the following:
mount | grep disk
/dev/sdb1 on /media/disk type vfat (rw,nosuid,nodev,uhelper=hal,shortname=lower,uid=500)

OK, so I know the phone is mounted on /dev/sdb, partition 1

udevinfo -q path -n /dev/sdb1
/devices/pci0000:00/0000:00:1d.3/usb5/5-2/5-2:1.0/host4/target4:0:0/4:0:0:0/block/sdb/sdb1

The udevinfo tells me to look at
/sys/block/sdb/sdb1
to get more info about the phone

Or use udevinfo to get a nice formatted output
udevinfo -a -p /block/sdb/sdb1 | more

In /etc/udev/rules.d I created the file
10-udev-default.rules

in this file I added the rule
KERNEL=="sd[a-z]1", BUS=="scsi", SYSFS{vendor}=="Motorola", SYSFS{model}=="RAZRV3xx", NAME="%k", SYMLINK="/razr"

My /etc/fstab is updated with
/dev/sdb1 /media/razr vfat defaults 0 0


Thats the first part over.... to be continued

No comments: