[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: hotplug script before udev



David Berg wrote:
I'm trying to automount my digital camera (mass storage) when it is
connected.  I have udev scripts to give me a /dev/camera symlink which
appears to be working, and created a map in hotplug to call a script
called photodl which seems to be getting called.

The problem is that photodl is called before the device is created from udev.

dberg@chip:/var/log$ tail daemon.log
Mar  8 11:01:00 localhost udev[7397]: configured rule in
'/etc/udev/rules.d/10-local.rules[1]' applied, 'sdd1' becomes '%k'
Mar  8 11:01:00 localhost udev[7397]: creating device node '/dev/sdd1'
dberg@chip:/var/log$ tail messages
Mar  8 11:00:54 localhost kernel: sdd: assuming Write Enabled
Mar  8 11:00:54 localhost kernel:  /dev/scsi/host6/bus0/target0/lun3: p1
Mar  8 11:00:54 localhost kernel: Attached scsi removable disk sdd at
scsi6, channel 0, id 0, lun 3
Mar  8 11:00:55 localhost scsi.agent[7300]:      sd_mod: loaded
sucessfully (for disk)
Mar  8 11:00:55 localhost scsi.agent[7332]:      sd_mod: loaded
sucessfully (for disk)
Mar  8 11:00:55 localhost scsi.agent[7349]:      sd_mod: loaded
sucessfully (for disk)
Mar  8 11:00:55 localhost usb.agent[7311]:      usb-storage: already loaded
Mar  8 11:00:55 localhost usb.agent[7311]:      photodl: loaded successfully


Note that photodl is "loaded successfuly" at 11:00:55 and my rule in
10-local.rules is applied at 11:01:00.  5 seconds later.  I've added a
`sleep 10` command before the mount command in photodl but that didn't
help.

How can I ensure that photodl is run after the device is created?

I think the most reliable way is to use the PROGRAM key in your udev
rule for the device. The following is an example for a PCMCIA network card:

KERNEL=="eth*", SYSFS{address}=="xx:xx:xx:xx:xx:xx", NAME="wlan0", PROGRAM="/path/to/your/script"

(all on the same line)

/path/to/your/script should point to your script. It will be called
whenever the device is created or removed. In the script you can check
the $ACTION environmental variable ("add" or "remove") to know which
event occurred. The manpage of udev has more details.

Regards,
           Florian



Reply to: