#! /bin/sh
### BEGIN INIT INFO
# Provides:          mountvirtfs
# Required-Start:
# Required-Stop:
# Default-Start:     S
# Default-Stop:
# Short-Description: Mount virtual (kernel) file systems.
# Description:       Mount initial set of virtual filesystems the kernel
#                    provides and that are required by everything.
### END INIT INFO

# Script needs to be robust and continue when parts fail,
# so we're not setting the "-e" flag.
#set -e

PATH=/lib/init:/bin:/sbin

. /lib/init/functions.sh

KERNEL=`uname -s`
umask 022

do_start () {
	# Mount standard /proc filesystem
    	TYPE=
	case "$KERNEL" in
	    Linux|GNU)
		TYPE=proc
		;;
	    *FreeBSD)
		TYPE=linprocfs
		;;
	    *)
		TYPE=procfs
		;;
	esac

	# Mount standard /proc and /sys.
	domount $TYPE /proc
	domount sysfs /sys

	# Mount /var/run and /var/lock as tmpfs.
	# /var may be on another drive so create /var/run if we need to
	domount tmpfs /var/run "-o mode=0755"
	domount tmpfs /var/lock "-o mode=1777"

	# Mount /proc/bus/usb -- though all software should be modified to
	# use /dev/bus/usb instead now
	domount usbfs /proc/bus/usb
}

case "$1" in
    start)
        do_start
        ;;
    restart|reload|force-reload)
        echo "Error: argument '$1' not supported" >&2
        exit 3
        ;;
    stop)
        ;;
    *)
        echo "Usage: $0 start|stop" >&2
        exit 3
        ;;
esac
