#!/bin/sh
#
### BEGIN INIT INFO
# Required-Start: $local_fs
# Default-Start:  2 3 4 5
# Description: Hide an Ethernet card from Xen Domain0
### END INIT INFO

check_if_loaded_or_in_kernel() {
	if [ -d /sys/bus/pci/drivers/pciback ] ; then
		echo "Xen pciback driver already loaded"
		exit 0
	fi
}

hide_me() {
    /sbin/modprobe -r 3c59x
#    /sbin/modprobe -r sis190
    /sbin/modprobe pciback

# The following code is not needed if you have an 
# entry like the following in /etc/modprobe.conf:
#
#     options pciback hide=(00:09.0)
#  
# This is just here as a manual example.
#
#    if [ $? = 1 ] ; then
#		echo "ERROR: Modprobe of pciback module failed"
#    else
#		cd /sys/bus/pci/drivers/3c59x
#		echo -n "0000:00:09.0" > unbind
#		cd /sys/bus/pci/drivers/pciback
#		echo -n "0000:00:09.0" > new_slot
#		echo -n "0000:00:09.0" > bind
#		echo "SUCCESS: 3com Ethernet card hidden from domain0"
#    fi

}

case "$1" in
  start)
    check_if_loaded_or_in_kernel
	hide_me
    ;;
  stop)
	echo "Xen pciback: No reason to unhide"
    ;;
  *)
	echo "Usage: $0 {start|stop}"
    exit 1
esac

exit $?
