View | Details | Raw Unified
Collapse All | Expand All

(-) hdparm.orig (-88 / +88 lines)
 Lines 21-132    Link Here 
# run hdparm.
# run hdparm.
depend() {
depend() {
    before bootmisc
	before bootmisc
}
}
do_hdparm() {
do_hdparm() {
    if [[ ${args:=$all_args} ]]
	if [[ ${args:=$all_args} ]]
    then
	then
		orgdevice=`readlink -f $device`
		orgdevice=`readlink -f $device`
		if [ -b $orgdevice ]; then
		if [ -b $orgdevice ]; then
	        ebegin "Running hdparm on $device"
			ebegin "Running hdparm on $device"
		    hdparm $args $device > /dev/null || ewarn "Failed to run hdparm on $device"
			hdparm $args $device > /dev/null || ewarn "Failed to run hdparm on $device"
		fi
		fi
    fi
	fi
}
}
start() {
start() {
    ebegin 'Starting hdparm'
	ebegin 'Starting hdparm'
    which hdparm &>/dev/null
	which hdparm &>/dev/null
    eend $? 'hdparm executable not found'
	eend $? 'hdparm executable not found'
    if [ -e /dev/.devfsd ] || [ -e /dev/.udev ]
	if [ -d /dev/ide ]
    then
	then
		# devfs and udev system
		# devfs and udev system
        for device in $(find /dev/ide -name disc)
		for device in $(find /dev/ide -name disc)
        do
		do
            args=''
			args=''
            for alias in /dev/hd?
			for alias in /dev/hd?
            do
			do
                if [ $alias -ef $device ]
				if [ $alias -ef $device ]
                then
				then
                    device=$alias
					device=$alias
                    eval args=\${`basename $alias`_args}
					eval args=\${`basename $alias`_args}
                    break
					break
                fi
				fi
            done
			done
            [ -z "$args" ] && for alias in /dev/discs/*
			[ -z "$args" ] && for alias in /dev/discs/*
            do
			do
                if [ $alias/disc -ef $device ]
				if [ $alias/disc -ef $device ]
                then
				then
                    device=$alias/disc
					device=$alias/disc
                    eval args=\${`basename $alias`_args}
					eval args=\${`basename $alias`_args}
                    break
					break
                fi
				fi
            done
			done
            do_hdparm
			do_hdparm
        done
		done
        for device in $(find /dev/ide -name cd)
		for device in $(find /dev/ide -name cd)
        do
		do
            args=''
			args=''
            for alias in /dev/hd?
			for alias in /dev/hd?
            do
			do
                if [ $alias -ef $device ]
				if [ $alias -ef $device ]
                then
				then
                    device=$alias
					device=$alias
                    eval args=\${`basename $alias`_args}
					eval args=\${`basename $alias`_args}
                    break
					break
                fi
				fi
            done
			done
			[ -z $args ] && for alias in /dev/cdroms/*
			[ -z $args ] && for alias in /dev/cdroms/*
            do
			do
                if [ $alias -ef $device ]
				if [ $alias -ef $device ]
				then
				then
                    device=$alias
					device=$alias
                    eval args=\${`basename $alias`_args}
					eval args=\${`basename $alias`_args}
                    break
					break
                fi
				fi
            done
			done
            do_hdparm
			do_hdparm
        done
		done
        let count=0
		let count=0
        # of course, the sort approach would fail here if any of the
		# of course, the sort approach would fail here if any of the
        # host/bus/target/lun numbers reached 2 digits..
		# host/bus/target/lun numbers reached 2 digits..
        for device in $(find /dev/ide -name generic | sort)
		for device in $(find /dev/ide -name generic | sort)
        do
		do
            eval args=\${generic${count}_args}
			eval args=\${generic${count}_args}
            do_hdparm
			do_hdparm
            let count=count+1
			let count=count+1
        done
		done
    else
	else
        # non-devfs system
		# non-devfs system
        for device in /dev/hd?
		for device in /dev/hd?
        do
		do
            # check that the block device really exists
			# check that the block device really exists
            # by opening it for reading
			# by opening it for reading
            if [ -b $device ] && ( : <$device ) 2>/dev/null
			if [ -b $device ] && ( : <$device ) 2>/dev/null
            then
			then
                eval args=\${`basename $device`_args}
				eval args=\${`basename $device`_args}
                do_hdparm
				do_hdparm
            fi
			fi
        done
		done
    fi
	fi
}
}