Skip to contentSkip to conversation

udev PROGRAM action

DISCUSSION Miles Roper 3 participants 3 messages Aug 24, 2005

lore
Share & tools
lore
#0 lore raw

Hi,

I've been trolling around the net trying to find an answer to why I can't get udev to correctly run a remove event in a script.

here is my udev line

BUS="usb", KERNEL="sd*", NAME="%k", PROGRAM="/etc/udev/scripts/usb.sh %k"

this works fine. it calls the script below...

#! /bin/sh
#
# Mount Hotplug Device
#

. /etc/thinstation.env
. $TS_GLOBAL

get_filesystems

if [ ! -e /mnt/usbdevice ]; then
mkdir /mnt/usbdevice
fi

case $ACTION in
add)
mkdir /mnt/usbdevice/$1
mount -t supermount -o fs=$filesystem,dev=/dev/$1 /mnt/usbdevice/$1 /mnt/usbdevice/$1
;;
remove)
umount /mnt/usbdevice/$1
rmdir /mnt/usbdevice/$1
;;
esac

exit 0

the add event works great. however, the remove event never gets actioned. In fact the script never gets run when the device is removed. any ideas why?

Thanks

Miles

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#1 lore raw
Quoted 10 lines · Miles Roper

Hi,

I've been trolling around the net trying to find an answer to why I can't get udev to correctly run a remove event in a script.

here is my udev line

BUS="usb", KERNEL="sd*", NAME="%k", PROGRAM="/etc/udev/scripts/usb.sh %k"

this works fine. it calls the script below...

...

Quoted 3 lines

the add event works great. however, the remove event never gets actioned. In fact the script never gets run when the device is removed. any ideas why?

PROGRAM is for evaluation of the device name. It is called before the device node is created. If you have NAME in a rule, the rule will never be called for any ather action than "add". Just remove "NAME="%k".

And better use RUN, it is called after device node handling.

Kay

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#2 lore raw
In reply to Miles Roper
Quoted 1 line · Kay Sievers

And better use RUN, it is called after device node handling.

for umounting, it may not be the best idea...

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel