#!/sbin/runscript
# Copyright 1999-2003 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# $Header: /home/cvsroot/gentoo-src/rc-scripts/init.d/localmount,v 1.15 2003/02/28 15:45:35 azarah Exp $


depend() {
	need checkfs
}

start() {
	# Mount local filesystems in /etc/fstab.
	ebegin "Mounting local filesystems"
	mount -at nocoda,nonfs,noproc,noncpfs,nosmbfs,noshm >/dev/null
	eend $? "Some local filesystem failed to mount"

	# Check what kernel we are running ...
	if [ "$(get_KV)" -ge "$(KV_to_int '2.5.0')" ]
	then
		USBFS="usbfs"
	else
		USBFS="usbdevfs"
	fi

	# Cache whether USBFS is 
	USBBOOL="$(egrep "${USBFS}" /proc/filesystems)"

	# Mount usbdevfs if kernel have support
	if [ -z "${USBBOOL}" ]
	then
		# >/dev/null to hide errors from non-USB users
		modprobe usbcore &>/dev/null
	fi
	if [ -n "${USBBOOL}" ] && \
	   [ -e /proc/bus/usb -a ! -e /proc/bus/usb/devices ]
	then
		ebegin "Mounting USB device filesystem (${USBFS})"
		mount -t ${USBFS} ${USBFS} /proc/bus/usb &>/dev/null
		eend $? "Failed to mount USB device filesystem"
	fi

	#swap on loopback devices, and other weirdnesses
	ebegin "Activating (possibly) more swap"
	/sbin/swapon -a &>/dev/null
	eend 0
}


# vim:ts=4
