[ltp] How does /proc/acpi/ibm/bay work

Tino Keitel linux-thinkpad@linux-thinkpad.org
Wed, 30 Mar 2005 09:59:53 +0200


--XsQoSWH+UP9D9v3l
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Tue, Mar 29, 2005 at 18:39:56 -0500, Nate wrote:
> I think what might help would be to provide the code inside the scripts, 
> if it's not too much trouble.

Well, here are the scripts from the 0.10 release, which I use. The
idectl calls result in hdparm -U and hdparm -R calls for the
corresponding IDE interface.

Regards,
Tino

--XsQoSWH+UP9D9v3l
Content-Type: application/x-sh
Content-Disposition: attachment; filename="eject.sh"
Content-Transfer-Encoding: quoted-printable

#!/bin/bash=0A=0A/bin/sync=0A/usr/local/sbin/idectl 1 off=0A=0A/bin/echo ej=
ect > /proc/acpi/ibm/bay=0A
--XsQoSWH+UP9D9v3l
Content-Type: application/x-sh
Content-Disposition: attachment; filename="rescan.sh"
Content-Transfer-Encoding: quoted-printable

#!/bin/bash=0A/bin/sleep 1=0A/bin/sync=0A/usr/local/sbin/idectl 1 rescan=0A
--XsQoSWH+UP9D9v3l
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=idectl

#!/bin/sh

HDPARM=/sbin/hdparm
MAX_IDE_NR=1

IDE_IO_0=0x1f0
IDE_IO_1=0x170

USE_IDE_DEV_0=/dev/hdc
USE_IDE_DEV_1=/dev/hda

usage () {
	if [ $# -gt 0 ]; then
		echo $* >&2
		echo
	fi

	echo "usage: $0 ide-channel-nr [off|on|rescan]" 2>&1
	exit 1
}

IDE_NR=$1
MODE=$2

do_register=0
do_unregister=0


if [ ! "$IDE_NR" ] || [ $IDE_NR -lt 0 ] || [ $IDE_NR -gt $MAX_IDE_NR ]; then
	usage "Unrecognized IDE-channel number"
fi

case "$MODE" in
on )		do_register=1 ;;
off )		do_unregister=1 ;;
rescan )	do_unregister=1; do_register=1 ;;
* )			usage "Unrecognized command" ;;
esac

eval "IDE_IO=\$IDE_IO_$IDE_NR"
eval "USE_IDE_DEV=\$USE_IDE_DEV_$IDE_NR"

[ $do_unregister -eq 1 ] && eval "$HDPARM -U $IDE_NR $USE_IDE_DEV > /dev/null"
[ $do_register -eq 1 ] && eval "$HDPARM -R $IDE_IO 0 0 $USE_IDE_DEV > /dev/null"


--XsQoSWH+UP9D9v3l--