#!/bin/bash
echo "IDE devices:"
if ! pushd /proc/ide 2> /dev/null > /dev/null; then
    exit 0
fi

getparam()
{
    D=$1
    N=$2
    rc=`grep $N /proc/ide/$D/settings | awk '{ print $2 }'`
    return $rc
}

for s in hd?; do
    if [ "$s" == "hd?" ]; then
		echo " * no IDE devices found" | csed '/./ p green,bold'
		exit
    fi
    D=${s##*/}
    T=`cat /proc/ide/$D/media`
    model=`cat /proc/ide/$D/model`
#    if [ "$T" == "cdrom" ]; then
#	continue
#    fi
    if getparam $s using_dma; then
        echo " * /dev/$D $model -- not using DMA-mode" | csed '/.*/ p red,bold'
    fi
    if getparam $s io_32bit; then
        echo " * /dev/$D $model -- not using 32-bit I/O" | csed '/.*/ p red,bold'
    fi
    if getparam $s unmaskirq; then
        echo " * /dev/$D $model -- not using unmaskirq mode" | csed '/.*/ p red,bold'
    fi
done
