[ltp] hotplugging IDE-devices

David Tansey linux-thinkpad@linux-thinkpad.org
Sat, 30 Oct 2004 23:00:46 -0400


here are my dock/undock scripts. you have to use idectl, which is
usually included with hdparm.

dock.sh:
#!/bin/bash

status=`/usr/bin/awk '/^present:/ { print $2 }' /proc/acpi/ibm/dock`

if [ "$status" == "yes" ]; then
        /bin/sync
        /bin/echo dock > /proc/acpi/ibm/dock
        /usr/local/sbin/idectl 1 rescan
fi

undock.sh:
#!/bin/bash

status=`/usr/bin/awk '/^present:/ { print $2 }' /proc/acpi/ibm/dock`

if [ "$status" == "yes" ]; then
        /bin/sync
        /usr/local/sbin/idectl 1 off
        if [ -L /proc/ide/hdc ]; then
                exit 1
        fi
        /bin/echo undock > /proc/acpi/ibm/dock
fi

i tested the line /usr/local/sbin/idectl off/on to make sure that 1 was
the right number. 

do you have your /etc/acpi/events directory set up to detect the right
event? just doing         /bin/echo undock > /proc/acpi/ibm/dock doesn't
do it.

events/dock:
event=(ibm/dock GDCK 00000000 00000003|ibm/hotkey HKEY 00000080
00001008)
action=/etc/acpi/dock.sh

events/undock:
event=(ibm/dock GDCK 00000000 00000003|ibm/hotkey HKEY 00000080
00001008)
action=/etc/acpi/dock.sh


enjoy! i'm loving ibm-acpi!!!

-david


On Sun, 2004-10-31 at 02:05 +0200, André Wyrwa wrote:
> Hei,
> 
> since ibm-acpi supports ultrabay and dock/undock events i just wanted to
> adjust the scripts for my machine.
> 
> Trouble is that when i do i.e. a hdparm -U 1 /dev/hdc (my combo drive),
> the thing would just say
>    /dev/hdc:
>    attempting to unregister hwif#1
> and nothing more.
> After that /proc/ide/ide1 still exists with the full file tree inside
> it.
> 
> I'm using 2.6.9 and udev. The ide driver is built into the kernel.
> 
> Any idea what might go wrong?
> 
> André.
> 
>