#!/bin/ash

. /etc/initrd.defaults
backup() {
	echo -ne "\033[0G\033[0K"
}

parse_opt() {
	case "$1" in
		*\=*)
			echo "$1" | cut -f2 -d=
		;;
	esac
}

modules_scan() {
	local MODS
	[ -d /etc/modules/${1} ] || touch /etc/modules/${1}

	MODS=`cat /etc/modules/${1}`
	for x in ${MODS}
	do
		echo -ne "${BOLD}   ::${NORMAL} Scanning for ${x}..."
		modprobe ${x} -n
		if [ $? -eq 0 ]
		then
			backup
			echo -e "${GOOD}   ::${NORMAL} Detected ${x} hardware..."
			continue
		fi
		backup
		echo -ne "${NORMAL}"
	done
}

findcdmount() {
	if [ "$#" -gt "0" ]
	then
		for x in $*
		do
			echo -e "${GOOD}>>${NORMAL} Attempting to mount CD:- ${x}"
			mount -t iso9660 -r ${x} /newroot/mnt/cdrom > /dev/null 2>&1
			if [ "$?" = "0" ]
			then
				REAL_ROOT="${x}"
				break
			fi
		done
		if [ "${REAL_ROOT}" != "" ]
		then
			echo -e "${GOOD}>>${NORMAL} CD medium found on $1"
		fi
	fi
}

kill_devfsd() {
	killall devfsd > /dev/null 2>&1
}
