# NFS filesystem mounting			-*- shell-script -*-

# FIXME This needs error checking

# Paramter: Where the root should be mounted
mountroot ()
{
	[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/nfsroot-top"
	run_scripts /scripts/nfsroot-top
	[ "$quiet" != "y" ] && log_end_msg

	if [ -e /tmp/NETDEV ]; then
          . /tmp/NETDEV
        else
          panic "no network device found!"
        fi

	touch /etc/mtab

	modprobe -Qb nfs
	. /tmp/net-${NETDEV}.conf

	if [ "x${NFSROOT}" = "xauto" ]; then
		NFSROOT=${ROOTSERVER}:${ROOTPATH}
	fi

	if [ "x${NFSOPTS}" = "x" ]; then
		NFSOPTS="-o retrans=10"
	fi

	[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/nfsroot-premount"
	run_scripts /scripts/nfsroot-premount
	[ "$quiet" != "y" ] && log_end_msg

	if [ ${readonly} = y ]; then
		roflag="-o ro"
	else
		roflag="-o rw"
	fi
	
	[ "$quiet" != "y" ] && _log_msg "Mounting NFS root at ${NFSROOT}"
	mount -o nolock ${roflag} ${NFSOPTS} ${NFSROOT} ${rootmnt}

	[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/nfsroot-bottom"
	run_scripts /scripts/nfsroot-bottom
	[ "$quiet" != "y" ] && log_end_msg

}
